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
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,33 @@ if errors.Is(err, ErrDriver) {
230
230
231
231
Why provide **two (2)** sentinels? It can often be useful to provide both a general purpose error — e.g. `ErrNotFound` — and a more-specific error — e.g. `ErrNoWidgetMatchedSearchTerm` — when characterizing errors.
232
232
233
+
## Parameter types for NewErr()
234
+
235
+
`NewErr(parts ...any)` accepts a variadic parameter, but **not all types are valid**:
Descriptive strings bypass `errors.Is()` and cannot be matched programmatically. If you need to describe a failure condition, create a sentinel error for it.
259
+
233
260
## Layered composition example
234
261
235
262
Each function layer defines **its own sentinel** and passes the error from the inner function as the trailing cause.
0 commit comments