errors

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidation

func IsValidation(err error) bool

IsValidation returns true if the error is a validation error.

func WriteResponse

func WriteResponse(w http.ResponseWriter, err error)

WriteResponse writes the instance of error to the response. This results in all errors being returned in a standard structure.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is a custom implementation of error, providing an error type and HTTP status code.

func New

func New(err string) *Error

New returns a new instance of Error, with the given error message.

func NewValidation

func NewValidation(err string) *Error

NewValidation returns a new instance of Error, with the typ "Validation".

func (*Error) Error

func (err *Error) Error() string

Error returns the error message.

func (*Error) MarshalJSON

func (err *Error) MarshalJSON() ([]byte, error)

MarshalJSON is a custom JSON marshal func used when writing the error to a http.ResponseWriter.

func (*Error) ParamName

func (err *Error) ParamName() *string

ParamName returns the error's paramName.

func (*Error) SetParamName

func (err *Error) SetParamName(name string) *Error

SetParamName sets the error's paramName property.

func (*Error) SetStatus

func (err *Error) SetStatus(statusCode int) *Error

SetStatus sets the status code of the error - this is used for the HTTP response.

func (*Error) SetType

func (err *Error) SetType(typ string) *Error

SetType sets the type of the error - this is used for the HTTP response.

func (*Error) Status

func (err *Error) Status() int

Status returns the error status code.

Jump to

Keyboard shortcuts

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