errors

package module
v0.0.0-...-a7baa06 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: MIT Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddErrorContext

func AddErrorContext(err error, field, message string) error

AddErrorContext adds a context to an error

func Cause

func Cause(err error) error

Cause gives the original error

func GetErrorContext

func GetErrorContext(err error) map[string]string

GetErrorContext returns the error context

func GetErrorDetail

func GetErrorDetail(err error) string

GetErrorDetail return the detail of a customError

func GetErrorMessage

func GetErrorMessage(err error) string

GetErrorMessage return the detail of a customError

func New

func New(msg string) error

New creates a no type error

func Newf

func Newf(msg string, args ...interface{}) error

Newf creates a no type error with formatted message

func Wrap

func Wrap(err error, msg string) error

Wrap an error with a string

func Wrapf

func Wrapf(err error, msg string, args ...interface{}) error

Wrapf an error with format string

Types

type ErrorType

type ErrorType uint

ErrorType is the type of an error

const (
	// NoType -
	NoType ErrorType = iota
	// BadRequest (400)
	BadRequest
	// Unauthorized (401)
	Unauthorized
	// Forbidden (403)
	Forbidden
	// NotFound (404)
	NotFound
	// MethodNotAllowed (405)
	MethodNotAllowed
	// PreconditionFailed (412)
	PreconditionFailed
	// UnsupportedMediaType (415)
	UnsupportedMediaType
	// InternalServerError (500)
	InternalServerError
	// NotImplemented (501)
	NotImplemented
	// ServiceUnavailable (503)
	ServiceUnavailable
)

func GetType

func GetType(err error) ErrorType

GetType returns the error type

func (ErrorType) New

func (errorType ErrorType) New(msg string) error

New creates a new customError

func (ErrorType) Newf

func (errorType ErrorType) Newf(msg string, args ...interface{}) error

Newf creates a new customError with formatted message

func (ErrorType) Wrap

func (errorType ErrorType) Wrap(err error, msg string) error

Wrap creates a new wrapped error

func (ErrorType) Wrapf

func (errorType ErrorType) Wrapf(err error, msg string, args ...interface{}) error

Wrapf creates a new wrapped error with formatted message

Jump to

Keyboard shortcuts

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