{"modulePath":"github.com/interspace/errors","version":"v1.2.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package errutil\n\nPackage errutil combines primitives from the library, the Go errors package and github.com/pkg/errors. It aims to serve as drop-in replacement to gitub.com/pkg/errors and replace the legacy implementation of \\`pgerrors\\`.\n\n## Functions\n\n```go\nfunc As(err error, target interface{}) bool\n```\nAs finds the first error in err's chain that matches the type to which target points, and if so, sets the target to its value and returns true. An error matches a type if it is assignable to the target type, or if it has a method As(interface{}) bool such that As(target) returns true. As will panic if target is not a non-nil pointer to a type which implements error or is of interface type.\n\nThe As method should set the target to its value and return true if err matches the type to which target points.\n\nNote: this implementation differs from that of xerrors as follows: - it also supports recursing through causes with Cause(). - if it detects an API use error, its panic object is a valid error.\n\n```go\nfunc AssertionFailedWithDepthf(depth int, format string, args ...interface{}) error\n```\nAssertionFailedWithDepthf creates an internal error with a stack trace collected at the specified depth. See the doc of \\`AssertionFailedf()\\` for more details.\n\n```go\nfunc AssertionFailedf(format string, args ...interface{}) error\n```\nAssertionFailedf creates an internal error.\n\nDetail is shown: - via \\`errors.GetSafeDetails()\\`, shows redacted strings. - when formatting with \\`%+v\\`. - in Sentry reports.\n\n```go\nfunc HandleAsAssertionFailure(origErr error) error\n```\nHandleAsAssertionFailure hides an error and turns it into an assertion failure. Both details from the original error and the context of the caller are preserved. The original error is not visible as cause any more. The original error message is preserved. See the doc of \\`AssertionFailedf()\\` for more details.\n\n```go\nfunc HandleAsAssertionFailureDepth(depth int, origErr error) error\n```\nHandleAsAssertionFailureDepth is like HandleAsAssertionFailure but the depth at which the call stack is captured can be specified.\n\n```go\nfunc New(msg string) error\n```\nNew creates an error with a simple error message. A stack trace is retained.\n\nDetail output: - message via \\`Error()\\` and formatting using \\`%v\\`/\\`%s\\`/\\`%q\\`. - everything when formatting with \\`%+v\\`. - stack trace (not message) via \\`errors.GetSafeDetails()\\`. - stack trace (not message) in Sentry reports.\n\n```go\nfunc NewAssertionErrorWithWrappedErrDepthf(\n\tdepth int, origErr error, format string, args ...interface{},\n) error\n```\nNewAssertionErrorWithWrappedErrDepthf is like NewAssertionErrorWithWrappedErrf but the depth at which the call stack is captured can be specified. See the doc of \\`AssertionFailedf()\\` for more details.\n\n```go\nfunc NewAssertionErrorWithWrappedErrf(origErr error, format string, args ...interface{}) error\n```\nNewAssertionErrorWithWrappedErrf wraps an error and turns it into an assertion error. Both details from the original error and the context of the caller are preserved. The original error is not visible as cause any more. The original error message is preserved. See the doc of \\`AssertionFailedf()\\` for more details.\n\n```go\nfunc NewWithDepth(depth int, msg string) error\n```\nNewWithDepth is like New() except the depth to capture the stack trace is configurable. See the doc of \\`New()\\` for more details.\n\n```go\nfunc NewWithDepthf(depth int, format string, args ...interface{}) error\n```\nNewWithDepthf is like Newf() except the depth to capture the stack trace is configurable. See the doc of \\`New()\\` for more details.\n\n```go\nfunc Newf(format string, args ...interface{}) error\n```\nNewf creates an error with a formatted error message. A stack trace is retained. See the doc of \\`New()\\` for more details.\n\n```go\nfunc WithMessage(err error, message string) error\n```\nWithMessage annotates err with a new message. If err is nil, WithMessage returns nil.\n\n```go\nfunc WithMessagef(err error, format string, args ...interface{}) error\n```\nWithMessagef annotates err with the format specifier. If err is nil, WithMessagef returns nil.\n\n```go\nfunc Wrap(err error, msg string) error\n```\nWrap wraps an error with a message prefix. A stack trace is retained.\n\nDetail output: - original error message + prefix via \\`Error()\\` and formatting using \\`%v\\`/\\`%s\\`/\\`%q\\`. - everything when formatting with \\`%+v\\`. - stack trace (not message) via \\`errors.GetSafeDetails()\\`. - stack trace (not message) in Sentry reports.\n\n```go\nfunc WrapWithDepth(depth int, err error, msg string) error\n```\nWrapWithDepth is like Wrap except the depth to capture the stack trace is configurable. The the doc of \\`Wrap()\\` for more details.\n\n```go\nfunc WrapWithDepthf(depth int, err error, format string, args ...interface{}) error\n```\nWrapWithDepthf is like Wrapf except the depth to capture the stack trace is configurable. The the doc of \\`Wrapf()\\` for more details.\n\n```go\nfunc Wrapf(err error, format string, args ...interface{}) error\n```\nWrapf wraps an error with a formatted message prefix. A stack trace is also retained. If the format is empty, no prefix is added, but the extra arguments are still processed for reportable strings.\n\nDetail output: - original error message + prefix via \\`Error()\\` and formatting using \\`%v\\`/\\`%s\\`/\\`%q\\`. - everything when formatting with \\`%+v\\`. - stack trace (not message) and redacted details via \\`errors.GetSafeDetails()\\`. - stack trace (not message) and redacted details in Sentry reports.\n\n","path":"github.com/interspace/errors/errutil","name":"errutil","synopsis":"Package errutil combines primitives from the library, the Go errors package and github.com/pkg/errors.","isRedistributable":true}
