mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 09:18:51 +02:00
refactor: fix lint errors; improve error handling
This commit is contained in:
@@ -125,7 +125,7 @@ func helpVar(varExpr string) string {
|
||||
}
|
||||
|
||||
/*
|
||||
Generate help string as error, e.g.
|
||||
Error generates help string as error, e.g.
|
||||
|
||||
rewrite <from> <to>
|
||||
from: the path to rewrite, must start with /
|
||||
|
||||
@@ -158,13 +158,14 @@ func parse(v string) (subject string, args []string, err error) {
|
||||
buf.WriteRune('$')
|
||||
}
|
||||
|
||||
if quote != 0 {
|
||||
switch {
|
||||
case quote != 0:
|
||||
err = ErrUnterminatedQuotes
|
||||
} else if brackets != 0 {
|
||||
case brackets != 0:
|
||||
err = ErrUnterminatedBrackets
|
||||
} else if inEnvVar {
|
||||
case inEnvVar:
|
||||
err = ErrUnterminatedEnvVar
|
||||
} else {
|
||||
default:
|
||||
flush(false)
|
||||
}
|
||||
if len(missingEnvVars) > 0 {
|
||||
|
||||
@@ -286,8 +286,7 @@ func logError(err error, r *http.Request) {
|
||||
var h2Err http2.StreamError
|
||||
if errors.As(err, &h2Err) {
|
||||
// ignore these errors
|
||||
switch h2Err.Code {
|
||||
case http2.ErrCodeStreamClosed:
|
||||
if h2Err.Code == http2.ErrCodeStreamClosed {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func NeedExpandVars(s string) bool {
|
||||
var (
|
||||
voidResponseModifier = httputils.NewResponseModifier(httptest.NewRecorder())
|
||||
dummyRequest = http.Request{
|
||||
Method: "GET",
|
||||
Method: http.MethodGet,
|
||||
URL: &url.URL{Path: "/"},
|
||||
Header: http.Header{},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user