Files
2026-05-25 08:38:26 +07:00

34 lines
710 B
Go

// 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} }