errdefs

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromStatusCode

func FromStatusCode(statusCode int, err error) error

FromStatusCode creates an errdef error, based on the provided HTTP status-code

func GetStatusCode

func GetStatusCode(err error) int

GetStatusCode retrieves status code from error message

func IsConflict

func IsConflict(err error) bool

IsConflict returns true if the passed in error is an errConflict

func IsForbidden

func IsForbidden(err error) bool

IsForbidden returns true if the passed in error is an errForbidden

func IsInvalidParameter

func IsInvalidParameter(err error) bool

IsInvalidParameter returns true if the passed in error is an errInvalidParameter

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the passed in error is an errNotFound

func IsNotImplemented

func IsNotImplemented(err error) bool

IsNotImplemented returns true if the passed in error is an errNotImplemented

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized returns true if the passed in error is an errUnauthorized

func IsUnknown

func IsUnknown(err error) bool

IsUnknown returns true if the passed in error is an errUnknown

Types

type Error

type Error struct {
	Text  string    `json:"text"`
	Type  ErrorType `json:"type"`
	Cause error     `json:"-"`
}

Error is a generic error type

func Conflict

func Conflict(err interface{}, args ...interface{}) Error

Conflict signals that the requested action cannot be performed in current system state

func Forbidden

func Forbidden(err interface{}, args ...interface{}) Error

Forbidden signals that the requested action cannot be performed under any circumstances

func InvalidParameter

func InvalidParameter(err interface{}, args ...interface{}) Error

InvalidParameter signals that the user input is invalid

func NotFound

func NotFound(err interface{}, args ...interface{}) Error

NotFound signals that the requested object doesn't exist

func NotImplemented

func NotImplemented(err interface{}, args ...interface{}) Error

NotImplemented signals that the requested action/feature is not implemented on the system as configured

func Unauthorized

func Unauthorized(err interface{}, args ...interface{}) Error

Unauthorized is used to signify that the user is not authorized to perform a specific action

func Unknown

func Unknown(err interface{}, args ...interface{}) Error

Unknown signals that the kind of error that occurred is not known

func (Error) CausedBy

func (e Error) CausedBy(cause error) Error

CausedBy adds error cause

func (Error) Error

func (e Error) Error() string

type ErrorType

type ErrorType string

ErrorType represents a basic error type

const (
	ErrNotFound         ErrorType = "not found"
	ErrInvalidParameter ErrorType = "invalid parameter"
	ErrUnauthorized     ErrorType = "unauthorized"
	ErrForbidden        ErrorType = "forbidden"
	ErrConflict         ErrorType = "conflict"
	ErrNotImplemented   ErrorType = "not implemented"
	ErrUnknown          ErrorType = "unknown"
)

Known error types

Jump to

Keyboard shortcuts

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