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
@@ -13,12 +13,18 @@ stack traces, tags(additional information) and even a Type classification system
13
13
Common Questions
14
14
15
15
Why another package?
16
-
Because IMO most of the existing packages either don't take the error handling far enough, too far or down right unfriendly to use/consume.
16
+
There are two main reasons.
17
+
- I think that the programs generating the original error(s) should be responsible for handling them, even though this package allows access to the original error, and that the callers are mainly interested in:
18
+
- If the error is Transient or Permanent for retries.
19
+
- Additional details for logging.
20
+
21
+
- IMO most of the existing packages either don't take the error handling far enough, too far or down right unfriendly to use/consume.
17
22
18
23
Features
19
24
--------
20
25
-[x] works with go-playground/log, the Tags will be added as Field Key Values and Types will be concatenated as well when using `WithError`
21
26
-[x] helpers to extract and classify error types using `RegisterHelper(...)`, many already existing such as ioerrors, neterrors, awserrors...
27
+
-[x] built in helpers only need to be imported, eg. `_ github.com/go-playground/errors/helpers/neterrors` allowing libraries to register their own helpers not needing the caller to do or guess what needs to be imported.
22
28
23
29
Installation
24
30
------------
@@ -44,15 +50,24 @@ func main() {
44
50
fmt.Println(err)
45
51
if errors.HasType(err, "Permanent") {
46
52
// os.Exit(1)
53
+
fmt.Println("it is a permanent error")
47
54
}
48
55
49
56
// root error
50
57
cause:= errors.Cause(err)
51
-
fmt.Println(cause)
58
+
fmt.Println("CAUSE:", cause)
52
59
53
60
// can even still inspect the internal error
54
61
fmt.Println(errors.Cause(err) == io.EOF) // will extract the cause for you
0 commit comments