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
Copy file name to clipboardExpand all lines: README.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,8 @@ func Foo() error {
28
28
29
29
### Adding stack trace
30
30
If you are interested in adding information about the line and filename where the sentinel error happened, you can do the following:
31
+
32
+
**NOTE**: While the `WithStack` will return `nil` if passed `err` equals `nil`, we do not consider this good practice and recommend checking the `err` value before invocation.
31
33
```go
32
34
funcFoo() error {
33
35
...
@@ -47,6 +49,8 @@ func Bar() error {
47
49
48
50
### Adding error cause information
49
51
Sometimes you might be interested in returning a sentinel error, but also add some cause error to it, in such cases you can do the following:
52
+
53
+
**NOTE**: While the `WithCause` will return `nil` if passed `err` equals `nil`, we do not consider this good practice and recommend checking the `err` value before invocation.
50
54
```go
51
55
funcFetchSomething(IDstring) error {
52
56
err:=doSomething() // Here we have an error
@@ -74,6 +78,8 @@ func FooBar() error {
74
78
75
79
### Wrapping an error with a high-level message
76
80
Sometimes you might want to add some high-level information to an error before passing it up to the invoker.
81
+
82
+
**NOTE**: While the `Wrap` will return `nil` if passed `err` equals `nil`, we do not consider this good practice and recommend checking the `err` value before invocation.
0 commit comments