diff --git a/main.go b/main.go index ecc3af5..02ca6d2 100644 --- a/main.go +++ b/main.go @@ -87,6 +87,9 @@ func do(req *gemini.Request, via []*gemini.Request) (*gemini.Response, *gemini.R redirect.URL = target return do(&redirect, via) } + if resp.Status.Class() != gemini.StatusSuccess { + return resp, req, errors.New(fmt.Sprintf("%d %s", resp.Status, resp.Meta)) + } return resp, req, err } @@ -112,9 +115,6 @@ func main() { } defer resp.Body.Close() - if resp.Status.Class() != gemini.StatusSuccess { - log.Fatalf("%d %s", resp.Status, resp.Meta) - } if resp.Meta != "text/gemini" && !strings.HasPrefix(resp.Meta, "text/gemini;") { log.Fatal("mime type is not text/gemini") }