Documentation
¶
Index ¶
- func ContextDone(err error) bool
- func DiscardAndClose(r io.ReadCloser, e *error)
- func NewUserError(msg string) error
- func NewUserErrorWithCause(cause error, msg string) error
- func SafeCall(toCall func() error, err *error)
- func SafeClose(toClose io.Closer, err *error)
- type Attachment
- type CaptureOption
- type CaptureOptions
- type ErrCapturer
- type ErrReporter
- type Level
- type UserError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextDone ¶
func DiscardAndClose ¶
func DiscardAndClose(r io.ReadCloser, e *error)
func NewUserError ¶
func NewUserErrorWithCause ¶
Types ¶
type Attachment ¶ added in v19.1.0
Attachment is an arbitrary blob attached to a captured error, such as a goroutine dump.
type CaptureOption ¶ added in v19.1.0
type CaptureOption func(*CaptureOptions)
CaptureOption configures a single ErrCapturer.Capture call.
func WithAttachment ¶ added in v19.1.0
func WithAttachment(filename, contentType string, payload []byte) CaptureOption
WithAttachment attaches a blob to the captured error.
func WithFields ¶ added in v19.1.0
func WithFields(fields ...slog.Attr) CaptureOption
WithFields attaches structured key/value fields to the captured error.
func WithLevel ¶ added in v19.1.0
func WithLevel(l Level) CaptureOption
WithLevel sets the severity of the captured error.
type CaptureOptions ¶ added in v19.1.0
type CaptureOptions struct {
Level Level
Fields []slog.Attr
Attachments []Attachment
}
CaptureOptions is the backend-neutral data accumulated for a captured error.
type ErrCapturer ¶ added in v19.1.0
type ErrCapturer interface {
Capture(ctx context.Context, err error, opts ...CaptureOption)
}
ErrCapturer forwards an error and optional metadata to an error-tracking backend. Unlike ErrReporter it neither logs nor inspects the error; it is the low-level primitive for sending an error report.
type ErrReporter ¶
type ErrReporter interface {
// HandleProcessingError can be used to handle errors occurring while processing a request.
// If err is a (or wraps a) errz.UserError, it might be handled specially.
HandleProcessingError(ctx context.Context, log *slog.Logger, msg string, err error, fields ...slog.Attr)
}
ErrReporter provides a way to report errors.
type Level ¶ added in v19.1.0
type Level byte
Level is the backend-neutral severity of a captured error. The zero value is LevelError, the common case.
type UserError ¶
type UserError struct {
// Message is a textual description of what's wrong.
// Must be suitable to show to the user.
Message string
// Cause optionally holds an underlying error.
Cause error
}
UserError is an error that happened because the user messed something up: - invalid syntax - invalid configuration