2024-01-16 21:53:03 -06:00
|
|
|
package errors
|
|
|
|
|
|
|
|
|
|
// ResponsableError is an error that has information useful in an HTTP response.
|
|
|
|
|
// The string returned by Error should be suitable for logging useful information
|
|
|
|
|
// to assist debugging the error.
|
|
|
|
|
// Status should return an appropriate HTTP status.
|
|
|
|
|
// Msg should return a message suitable to display to the end user. If the message
|
|
|
|
|
// returned by Error is safe for the end user, it may simply call that.
|
|
|
|
|
type ResponsableError interface {
|
|
|
|
|
Error() string
|
|
|
|
|
Status() int
|
|
|
|
|
Msg() string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UnwrappableError allows a ResponsableError to wrap another error.
|
|
|
|
|
// It may be appropriate for Error() to delegate to the wrapped error.
|
|
|
|
|
type UnwrappableError interface {
|
|
|
|
|
ResponsableError
|
|
|
|
|
Unwrap() error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UnwrappableErrorrs allows a ResponsableError to wrap multiple errors.
|
|
|
|
|
// It may be appropriate for Error() to either delegate to the first error,
|
|
|
|
|
// the last error, or to concatenate the return values of all wrapped errors,
|
|
|
|
|
// similar to errors returned by errors.Join
|
|
|
|
|
type UnwrappableErrors interface {
|
|
|
|
|
ResponsableError
|
|
|
|
|
Unwrap() []error
|
|
|
|
|
}
|
2024-01-17 10:58:39 -06:00
|
|
|
|
|
|
|
|
type wrappedError interface {
|
|
|
|
|
Error() string
|
|
|
|
|
Unwrap() error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type wrappedErrors interface {
|
|
|
|
|
Error() string
|
|
|
|
|
Unwrap() []error
|
|
|
|
|
}
|