Documentation
¶
Index ¶
- Variables
- func AggregateToResponse(data interface{}, errResponse ErrorResponse) bool
- func Wrap(reason error, options ...Option) 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 ErrorWithReason
- type HttpError
- type ModuleError
- type Option
- type ValidationError
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 ¶
WrapCode 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 ¶
ErrorWithCode implements an error with a code related to it.
type ErrorWithMessage ¶
ErrorWithMessage implements an error with a code related to it.
type ErrorWithReason ¶
ErrorWithReason is an error that has an main reason because it was raised. It is used to wrap more abstract errors with improved messages for the customer.
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) Reason ¶
func (err *ValidationError) Reason() error