-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.go
More file actions
43 lines (33 loc) · 1.6 KB
/
doc.go
File metadata and controls
43 lines (33 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
Package errors is a drop-in replacement for the standard library "errors" package
that adds stack trace capture, gRPC status codes, and error notification support.
The following standard library helpers are re-exported:
[Is], [As], [Unwrap], [Join], and the [ErrUnsupported] sentinel.
This allows you to use this package as your sole errors import:
import "github.com/go-coldbrew/errors"
// Standard library functions work as expected:
errors.Is(err, target)
errors.As(err, &target)
errors.Unwrap(err)
errors.Join(err1, err2)
// ColdBrew extensions add stack traces and gRPC status:
errors.New("something failed") // captures stack trace
errors.Wrap(err, "context") // wraps with stack trace
errors.Cause(err) // walks Unwrap chain to root cause
# Error Creation
The simplest way to use this package is by calling one of the two functions:
errors.New(...)
errors.Wrap(...)
You can also initialize custom error stack by using one of the WithSkip functions. WithSkip allows
skipping the defined number of functions from the stack information.
New — create a new error with stack info
NewWithSkip — skip functions on the stack
NewWithStatus — add GRPC status
NewWithSkipAndStatus — skip functions and add GRPC status
Wrap — wrap an existing error
WrapWithStatus — wrap and add GRPC status
WrapWithSkip — wrap and skip functions on the stack
WrapWithSkipAndStatus — wrap, skip functions, and add GRPC status
Head to https://docs.coldbrew.cloud for more information.
*/
package errors