failures

package
v0.0.0-...-1aaf8f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
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

func New(err error, params map[string]interface{}) Failure

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 NewBindFailure(err error) Failure

func NewFieldEmptyFailure

func NewFieldEmptyFailure(paramName string) Failure

func NewGeneralFailure

func NewGeneralFailure(err error, failureType int) Failure

NewGeneralFailure creates a Failure with all basic parameters coming from the caller. No assumptions about message format are made by the system.

func NewParamInvalidType

func NewParamInvalidType(paramName string, expectedType string) Failure

func NewParamNotFound

func NewParamNotFound(paramName string) Failure

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL