dasherr

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Structured errors for Dashborg providing a wrapped error with error codes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsProtoErr added in v0.7.2

func AsProtoErr(err error) *dashproto.ErrorType

Creates a dashproto.ErrorType from the fields of DashErr

func CanRetry

func CanRetry(err error) bool

If err is a DashErr, returns CanRetry(), otherwise returns true.

func ErrWithCode

func ErrWithCode(code ErrCode, err error) error

Wraps err into a DashErr with the given error code

func ErrWithCodeStr

func ErrWithCodeStr(code ErrCode, errStr string) error

Wraps errStr into a DashErr with the given error code

func FromProtoErr added in v0.7.2

func FromProtoErr(perr *dashproto.ErrorType) error

Turns a dashproto.ErrorType into a DashErr

func FromRtnStatus

func FromRtnStatus(apiName string, rtnStatus *dashproto.RtnStatus) error

Creates a DashErr from a gRPC RtnStatus

func GetMessage added in v0.7.1

func GetMessage(err error) string

If err is a DashErr, unwraps it to return the inner error message, otherwise just calls Error().

func JsonMarshalErr

func JsonMarshalErr(thing string, err error) error

Creates a DashErr from a json.Marshal error

func JsonUnmarshalErr

func JsonUnmarshalErr(thing string, err error) error

Creates a DashErr from a json.Unmarshal error

func LimitErr

func LimitErr(message string, limitName string, limitMax float64) error

Creates a DashErr around an exceeded account limit.

func MakeDashErr

func MakeDashErr(code ErrCode, isPermanent bool, err error) error

Creates a DashErr

func NoRetryErr

func NoRetryErr(err error) error

Wraps err into a DashErr with no-retry set.

func NoRetryErrWithCode

func NoRetryErrWithCode(code ErrCode, err error) error

Wraps err into a DashErr with the given error code and no-retry set.

func RpcErr

func RpcErr(apiName string, respErr error) error

Creates a DashErr from a gRPC error

func ValidateErr

func ValidateErr(err error) error

Creates a validation DashErr

Types

type DashErr

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

func AsDashErr

func AsDashErr(err error) *DashErr

If err is a DashErr, returns it, otherwise wraps it into a DashErr struct.

func (*DashErr) CanRetry

func (e *DashErr) CanRetry() bool

func (*DashErr) ErrCode

func (e *DashErr) ErrCode() ErrCode

func (*DashErr) Error

func (e *DashErr) Error() string

func (*DashErr) Unwrap

func (e *DashErr) Unwrap() error

type ErrCode

type ErrCode string
const (
	ErrCodeNone         ErrCode = ""
	ErrCodeEof          ErrCode = "EOF"
	ErrCodeUnknown      ErrCode = "UNKNOWN"
	ErrCodeBadConnId    ErrCode = "BADCONNID"
	ErrCodeAccAccess    ErrCode = "ACCACCESS"
	ErrCodeNoHandler    ErrCode = "NOHANDLER"
	ErrCodeBadAuth      ErrCode = "BADAUTH"
	ErrCodeRoleAuth     ErrCode = "BADROLE"
	ErrCodeBadZone      ErrCode = "BADZONE"
	ErrCodeNoAcc        ErrCode = "NOACC"
	ErrCodeOffline      ErrCode = "OFFLINE"
	ErrCodePanic        ErrCode = "PANIC"
	ErrCodeJson         ErrCode = "JSON"
	ErrCodeRpc          ErrCode = "RPC"
	ErrCodeUpload       ErrCode = "UPLOAD"
	ErrCodeLimit        ErrCode = "LIMIT"
	ErrCodeNotConnected ErrCode = "NOCONN"
	ErrCodeValidation   ErrCode = "NOTVALID"
	ErrCodeQueueFull    ErrCode = "QUEUE"
	ErrCodeTimeout      ErrCode = "TIMEOUT"
	ErrCodeNotImpl      ErrCode = "NOTIMPL"
	ErrCodePathNotFound ErrCode = "NOTFOUND"
	ErrCodeBadPath      ErrCode = "BADPATH"
	ErrCodeNoApp        ErrCode = "NOAPP"
	ErrCodeProtocol     ErrCode = "PROTOCOL"
	ErrCodeInitErr      ErrCode = "INITERR"
)

func GetErrCode

func GetErrCode(err error) ErrCode

If err is a DashErr returns the error code, otherwise returns "" for non-DashErr errors.

Jump to

Keyboard shortcuts

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