errors

Package errors provides simple error handling primitives. The traditional error handling idiom in Go is roughly akin to which when applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. The e.Wrap function returns a new error that adds context to the original error by recording a stack trace at the point Wrap is called, together with the supplied message. For example If additional control is required, the e.WithStack and e.WithMessage functions destructure e.Wrap into its component operations: annotating an error with a stack trace and with a message, respectively. Using e.Wrap constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of e.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by e.Cause. e.Cause will recursively retrieve the topmost error that does not implement causer, which is assumed to be the original cause. For example: Although the causer interface is not exported by this package, it is considered a part of its stable public interface. All error values returned from this package implement fmt.Formatter and can be formatted by the fmt package. The following verbs are supported: New, Errorf, Wrap, and Wrapf record a stack trace at the point they are invoked. This information can be retrieved with the following interface: The returned e.StackTrace type is defined as The Frame type represents a call site in the stack trace. Frame supports the fmt.Formatter interface that can be used for printing information about the stack trace of this error. For example: Although the stackTracer interface is not exported by this package, it is considered a part of its stable public interface. See the documentation for Frame.Format for more details.

MIT License

Stars
1
Committers
2

Commit Statistics

Past Year

All Time

Total Commits
26
43
Total Committers
2
2
Avg. Commits Per Committer
13.0
21.5
Bot Commits
12
14

Issue Statistics

Past Year

All Time

Total Pull Requests
17
30
Merged Pull Requests
17
30
Total Issues
2
2
Time to Close Issues
21 days
21 days