File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -7,19 +7,27 @@ import (
7
7
8
8
// DontLog wraps the passed error
9
9
// so that ShouldLog returns false.
10
+ // A nil error won't be wrapped but returned as nil.
10
11
//
11
- // httperr.ShouldLog(httperr.BadRequest) == true
12
- // httperr.ShouldLog(httperr.DontLog(httperr.BadRequest)) == false
12
+ // httperr.ShouldLog(httperr.BadRequest) == true
13
+ // httperr.ShouldLog(httperr.DontLog(httperr.BadRequest)) == false
13
14
func DontLog (err error ) error {
15
+ if err == nil {
16
+ return nil
17
+ }
14
18
return errDontLog {err }
15
19
}
16
20
17
21
// ShouldLog checks if the passed error
18
22
// has been wrapped with DontLog.
23
+ // A nil error results in false.
19
24
//
20
- // httperr.ShouldLog(httperr.BadRequest) == true
21
- // httperr.ShouldLog(httperr.DontLog(httperr.BadRequest)) == false
25
+ // httperr.ShouldLog(httperr.BadRequest) == true
26
+ // httperr.ShouldLog(httperr.DontLog(httperr.BadRequest)) == false
22
27
func ShouldLog (err error ) bool {
28
+ if err == nil {
29
+ return false
30
+ }
23
31
var dontLog errDontLog
24
32
return ! errors .As (err , & dontLog )
25
33
}
You can’t perform that action at this time.
0 commit comments