Documentation ¶
Overview ¶
Package eerror stands for Encore Error and is used to provide a little more information about the underlying error's metadata.
It also provides helper methods for working with zerolog's context
Index ¶
- func BottomStackTraceFrom(err error) (rtn errors.StackTrace)
- func LogWithMeta(evt *zerolog.Event, err error) *zerolog.Event
- func MetaFrom(err error) map[string]any
- func New(module string, msg string, meta map[string]any) error
- func WithMeta(err error, meta map[string]any) error
- func Wrap(cause error, module string, msg string, meta map[string]any) error
- func ZeroLogConsoleExtraFormatter(event map[string]any, buf *bytes.Buffer) error
- func ZeroLogStackMarshaller(err error) interface{}
- type Error
- type StackFrame
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BottomStackTraceFrom ¶ added in v1.11.0
func BottomStackTraceFrom(err error) (rtn errors.StackTrace)
BottomStackTraceFrom returns the deepest stack trace from the given error
func LogWithMeta ¶
LogWithMeta merges in the metadata from the errors into the log context
func MetaFrom ¶
MetaFrom will return the merged metadata from any eerror.Error objects in the errors given. It will unwrap errors as it descends
func Wrap ¶
Wrap wraps the cause error with the given message and meta. If cause is nil, wrap returns nil
func ZeroLogConsoleExtraFormatter ¶ added in v1.11.0
ZeroLogConsoleExtraFormatter extracts the extra fields from the error and formats them for console output
This field can be passed to a zerolog.ConsoleWriter as it's ExtraFieldFormatter
func ZeroLogStackMarshaller ¶ added in v1.11.0
func ZeroLogStackMarshaller(err error) interface{}
ZeroLogStackMarshaller will encode the following in the Zerolog error stack field: - the deepest error stack trace - the error meta data collected from all errors
This can then be extracted by ZeroLogConsoleExtraFormatter
Types ¶
type Error ¶
type Error struct { Module string `json:"module"` // The module the error was raised in (normally the package name, but could be a larger "module" name) Message string `json:"message"` // The message of the error, it should be human-readable and should be low entropy (i.e. so multiple errors of the same can be grouped) Meta map[string]any `json:"meta"` // Metadata about the error, this can be high entropy as it isn't used to group errors Stack []*StackFrame `json:"stack"` // The stack trace of the error // contains filtered or unexported fields }
func (*Error) MarshalZerologObject ¶ added in v1.11.0
MarshalZerologObject provides a strongly-typed and encoding-agnostic interface to be implemented by types used with Event/Context's Object methods.
func (*Error) StackTrace ¶
func (e *Error) StackTrace() errors.StackTrace
StackTrace implements the StackTraceProvider interface for some libraries including ZeroLog, xerrors and Sentry