Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorMaker ¶
type ErrorMaker func(message string, args ...any) *StructuredError
func New ¶
func New(options ...ErrorMakerOption) ErrorMaker
New creates a new error maker. An error maker is a function that accepts an error message and a series of arguments. Args can be either key/value pairs, or an ErrorArg struct. "Key" is expected to be "stringy".
type ErrorMakerOption ¶
type ErrorMakerOption func(*StructuredError)
func WithDelimiter ¶
func WithDelimiter(delimiter string) ErrorMakerOption
WithDelimiter allows you to configure a StructuredError's arg delimiter.
func WithSlog ¶
func WithSlog(logger *slog.Logger) ErrorMakerOption
WithSlog tells the maker to call the provided logger Error method, using Args as key value pairs in the log. This happens when you create the error.
type StructuredError ¶
type StructuredError struct {
Message string
Args map[string]any
Delimiter string
Logger *slog.Logger
}
StructuredError is a way to craft errors using similar semantics to slog.
func (*StructuredError) Error ¶
func (se *StructuredError) Error() string
Error implements the Error value interface.
Click to show internal directories.
Click to hide internal directories.