You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(lint): relinted code base according to strengthened rules.
Following the refactoring of error switch statements, added tests
cases to cover all new code branches.
NOTE: remember not to apply the auto fix for errlint, as it
embarks into ambitious code rewrites that are broken.
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Copy file name to clipboardExpand all lines: api.go
+67-40Lines changed: 67 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,19 @@ package errors
5
5
6
6
import (
7
7
"encoding/json"
8
+
"errors"
8
9
"fmt"
9
10
"net/http"
10
11
"reflect"
11
12
"strings"
12
13
)
13
14
14
15
// DefaultHTTPCode is used when the error Code cannot be used as an HTTP code.
16
+
//
17
+
//nolint:gochecknoglobals // it should have been a constant in the first place, but now it is mutable so we have to leave it here or introduce a breaking change.
15
18
varDefaultHTTPCode=http.StatusUnprocessableEntity
16
19
17
-
// Error represents a error interface all swagger framework errors implement
20
+
// Error represents a error interface all swagger framework errors implement.
18
21
typeErrorinterface {
19
22
error
20
23
Code() int32
@@ -33,15 +36,15 @@ func (a *apiError) Code() int32 {
33
36
returna.code
34
37
}
35
38
36
-
// MarshalJSON implements the JSON encoding interface
39
+
// MarshalJSON implements the JSON encoding interface.
37
40
func (aapiError) MarshalJSON() ([]byte, error) {
38
41
returnjson.Marshal(map[string]any{
39
42
"code": a.code,
40
43
"message": a.message,
41
44
})
42
45
}
43
46
44
-
// New creates a new API error with a code and a message
47
+
// New creates a new API error with a code and a message.
0 commit comments