Documentation
¶
Index ¶
- Constants
- type Failure
- func New(err error, params map[string]interface{}) Failure
- func NewBindFailure(err error) Failure
- func NewFieldEmptyFailure(paramName string) Failure
- func NewGeneralFailure(err error, failureType int) Failure
- func NewParamInvalidType(paramName string, expectedType string) Failure
- func NewParamNotFound(paramName string) Failure
Constants ¶
const ( FailureBadRequest = iota FailureNotFound FailureServiceError )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Failure ¶
type Failure interface {
Error() string
HasError() bool
Trace() (string, error)
Type() (int, error)
}
Failure is a wrapper around the standard Golang error type that gives us more control for how to handle, log, and return it to the user. In addition to storing the root error that was thrown by calling code, it can provide a stack trace and logging information, should it be asked. Finally, each implementation of Failure provides a type, so that responses can be effectively returned to calling code.
func New ¶
New creates a new Failure. It determines the best failure based on the error and arguments passed in. If no error occurred, the response will be nil.
func NewBindFailure ¶
func NewFieldEmptyFailure ¶
func NewGeneralFailure ¶
NewGeneralFailure creates a Failure with all basic parameters coming from the caller. No assumptions about message format are made by the system.