Documentation ¶
Overview ¶
Package errors provides a means to return detailed information for a request error, typically encoded in JSON format. This package wraps standard library error handling features and offers additional stack trace capabilities.
Package errors provides the error functions
Index ¶
- Constants
- Variables
- func As(err error, target interface{}) bool
- func Cause(err error) error
- func CodeString(code Code) string
- func ErrorFormatJSON(i []error) string
- func Errorf(format string, args ...interface{}) error
- func Is(err, target error) bool
- func Join(errs ...error) error
- func Must[T any](v T, err error) T
- func New(message string) error
- func RegisterCode(code Code, val string)
- func Stack(v string) error
- func Stackf(format string, args ...interface{}) error
- func Unwrap(err error) error
- func WithStack(err error) error
- func Wrap(err error, message string) error
- func Wrapf(err error, format string, args ...interface{}) error
- type Code
- type ErrorFormatFunc
- type MultiError
- type String
- type ThreadSafeMultiError
- type Valuer
Constants ¶
const ( Success = Code(0) Error = Code(1) )
const (
UnsupportedError = String("unsupported error")
)
Variables ¶
var ( // Append is a helper function that will append more merr Append = merr.Append // ListFormatFunc is a helper function that will format the merr ListFormatFunc = merr.ListFormatFunc )
Functions ¶
func CodeString ¶ added in v0.0.6
func ErrorFormatJSON ¶ added in v0.0.3
func RegisterCode ¶
Types ¶
type Code ¶ added in v0.0.6
type Code int
func ErrInteger ¶ added in v0.0.6
ErrInteger creates a new error from a string
type ErrorFormatFunc ¶
type ErrorFormatFunc = merr.ErrorFormatFunc
ErrorFormatFunc is a helper function that will format the merr
type MultiError ¶
MultiError is an alias of `github.com/hashicorp/go-multierror`.Error
type String ¶ added in v0.0.3
type String string
type ThreadSafeMultiError ¶
type ThreadSafeMultiError struct { ErrorFormat ErrorFormatFunc // contains filtered or unexported fields }
ThreadSafeMultiError represents a collection of merr
func ThreadSafe ¶
func ThreadSafe(err error, fns ...ErrorFormatFunc) *ThreadSafeMultiError
ThreadSafe creates a new ThreadSafeMultiError collection
func (*ThreadSafeMultiError) Append ¶
func (e *ThreadSafeMultiError) Append(err error)
Append adds an error to the MultiError collection
func (*ThreadSafeMultiError) Error ¶
func (e *ThreadSafeMultiError) Error() string
Error returns the JSON representation of the MultiError collection
func (*ThreadSafeMultiError) Errors ¶
func (e *ThreadSafeMultiError) Errors() []error
Errors returns the merr collection
func (*ThreadSafeMultiError) Has ¶
func (e *ThreadSafeMultiError) Has(err any) error
Has checks if the MultiError collection has the given merr or not
func (*ThreadSafeMultiError) HasErrors ¶
func (e *ThreadSafeMultiError) HasErrors() bool
HasErrors checks if the MultiError collection has any merr
func (*ThreadSafeMultiError) Unsafe ¶
func (e *ThreadSafeMultiError) Unsafe() *MultiError
Unsafe returns the MultiError collection
type Valuer ¶ added in v0.0.6
type Valuer[T any] interface { Value() T // Value returns the encapsulated value. Error() string // Error returns the string representation of the error, satisfying the error interface. Unwrap() error // Unwrap returns the original error object. Is(err error) bool // Is determines if the current error was created by the given error. }
Valuer defines an interface for retrieving encapsulated values and error information. It provides a unified way to access different types of values and error information.
func Valued ¶ added in v0.0.6
Valued is a generic function that creates a Valuer interface object encapsulating a value and an error. Parameters:
v - The value to be encapsulated. err - The original error to be encapsulated.
Returns:
An object implementing the Valuer interface, encapsulating the given value and error.