Documentation
¶
Index ¶
- func FromError(ctx context.Context, err error) context.Context
- func New(ctx context.Context, text string) error
- func Newf(ctx context.Context, text string, args ...any) error
- func Wrap(ctx context.Context, err error, text string) error
- func Wrapf(ctx context.Context, err error, text string, args ...any) error
- type ErrorWithContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromError ¶
FromError accepts a current context and an error and returns the context from the 'most wrapped' ErrorWithContext, or the supplied `context` if no ErrorWithContext is wrapped by the supplied `err`.
func New ¶
New creates a new ErrorWithContext, capturing the specified context and a string for the error.
The error returned has a string representation of: "<text>"
func Newf ¶
Newf creates a new ErrorWithContext, capturing the specified context, a string and args to be substituted for any format specifiers in the string.
The error returned has a string representation of: "<text>"
func Wrap ¶
Wrap wraps a specified error, capturing the specified context and a string to use when representing the wrapped error.
The error returned has a string representation of: "<text>: <err>"
Types ¶
type ErrorWithContext ¶
type ErrorWithContext struct {
// contains filtered or unexported fields
}
ErrorWithContext wraps an error, capturing a context and a string used to wrap the wrapped error in the string representation of the error.
func (ErrorWithContext) Context ¶
func (err ErrorWithContext) Context() context.Context
Context returns the innermost context accessible from this error or any wrapped ErrorWithContext.
func (ErrorWithContext) Error ¶
func (err ErrorWithContext) Error() string
Error implements the error interface.
func (ErrorWithContext) Unwrap ¶
func (err ErrorWithContext) Unwrap() error
Unwrap implements unwrapping to return the wrapped error.