// Package apperr defines AppError, the single error type used across the // worker. Job handlers wrap any underlying driver error before returning so // river retry/log lines stay consistent with the api service. package apperr import ( "errors" "fmt" ) type AppError struct { Message string Err error } func (e *AppError) Error() string { if e.Err != nil { return fmt.Sprintf("%s: %v", e.Message, e.Err) } return e.Message } func (e *AppError) Unwrap() error { return e.Err } func As(err error) (*AppError, bool) { var ae *AppError if errors.As(err, &ae) { return ae, true } return nil, false } func Wrap(msg string, err error) *AppError { return &AppError{Message: msg, Err: err} }