Documentation ¶
Index ¶
- Variables
- func AggregateToResponse(data interface{}, errResponse ErrorResponse) bool
- func Is(err, target error) bool
- func Reason(err error) error
- func Wrap(reason error, options ...interface{}) error
- func WrapCode(reason error, code string) error
- func WrapHttp(reason error, status int) error
- func WrapMessage(reason error, code string) error
- func WrapModule(reason error, module string) error
- func WrapValidation(reason error) error
- type ErrorResponse
- type ErrorResponseAggregator
- type ErrorWithCode
- type ErrorWithMessage
- type ErrorWithValidation
- type HttpError
- type ModuleError
- type Option
- type ValidationError
- type Wrapper
Constants ¶
This section is empty.
Variables ¶
var New = errors.New
New is an alias for the default `errors.New`.
Functions ¶
func AggregateToResponse ¶
func AggregateToResponse(data interface{}, errResponse ErrorResponse) bool
AggregateToResponse add the error information pieces to the errResponse. Then, it tries to check its `Reason` (if the error is an `ErrorWithReason`) for more data. It goes upward until `Reason` is not found.
If at least one `ErrorResponseAggregator` is found it returns true, otherwise it returns false.
func WrapMessage ¶
WrapMessage creates a new instance of a Reportable error with the given code.
func WrapModule ¶
WrapModule wraps an original error with the module information, returning a new instance with the reason set.
func WrapValidation ¶
Types ¶
type ErrorResponse ¶
type ErrorResponse interface {
SetParam(name string, value interface{})
}
ErrorResponse is an abstraction of an error response that might, or not, be sent to the customer.
type ErrorResponseAggregator ¶
type ErrorResponseAggregator interface {
AppendData(response ErrorResponse)
}
ErrorResponseAggregator is an error that can modify an `ErrorResponse`. It, usually, adds more information to explain better the error.
type ErrorWithCode ¶
type ErrorWithCode interface {
Code() string
}
ErrorWithCode implements an error with a code related to it.
type ErrorWithMessage ¶
type ErrorWithMessage interface {
Message() string
}
ErrorWithMessage implements an error with a code related to it.
type ErrorWithValidation ¶
type ModuleError ¶
type ModuleError interface {
Module() string
}
ModuleError describes an error that belongs to a module.
type Option ¶
func Validation ¶
func Validation() Option
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError implements wrapping validation errors into a reportable
func (*ValidationError) AppendData ¶
func (err *ValidationError) AppendData(response ErrorResponse)
func (*ValidationError) Code ¶
func (err *ValidationError) Code() string
Code returns the "validation" error code.
func (*ValidationError) Error ¶
func (err *ValidationError) Error() string
func (*ValidationError) Errors ¶
func (err *ValidationError) Errors() map[string][]string
func (*ValidationError) Unwrap ¶
func (err *ValidationError) Unwrap() error
Unwrap returns the next error in the error chain. If there is no next error, Unwrap returns nil.