Documentation ¶
Index ¶
- type BaseError
- func (be BaseError) AddDetail(key string, detail any)
- func (be BaseError) DebugMessages() string
- func (be BaseError) Details() ErrDetails
- func (be BaseError) Error() string
- func (be BaseError) Is(err error) bool
- func (be BaseError) Kind() ErrKind
- func (be BaseError) Message() string
- func (be BaseError) Unwrap() error
- type ErrDetails
- type ErrKind
- type Error
- type HTTPError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseError ¶
type BaseError struct {
// contains filtered or unexported fields
}
BaseError generalizes an error structure which can be used for any type of error
func BaseErrorWrapper ¶ added in v1.0.14
BaseErrorWrapper creates a new BaseError by wrapping an existing Error
func NewBaseError ¶
func NewBaseError(kind ErrKind, errMsg string, err error, detail ErrDetails) BaseError
NewBaseError creates a new BaseError with the information provided
func ToBaseError ¶
ToBaseError creates a new BaseError with Kind found from err
func (BaseError) DebugMessages ¶
DebugMessages returns a string taking all nested and wrapped operations and errors into account.
func (BaseError) Details ¶
func (be BaseError) Details() ErrDetails
Details returns the detail maps of this BaseError.
func (BaseError) Is ¶
Is determines if an error is of type BaseError. This is used by the new wrapping and unwrapping features available in Go 1.13 and aids the errors.Is function when determining is an error or any error in the wrapped chain contains an error of a particular type.
type ErrDetails ¶
ErrDetails is a detailed mapping to set extra information with the error
type ErrKind ¶
type ErrKind string
ErrKind a categorical identifier used to give high-level insight as to the error type.
const ( // Constant Kind identifiers which can be used to label and group errors. KindUnknown ErrKind = "Unknown" KindDatabaseError ErrKind = "Database" KindCommunicationError ErrKind = "Communication" KindEntityDoesNotExist ErrKind = "NotFound" KindContractInvalid ErrKind = "ContractInvalid" KindServerError ErrKind = "UnexpectedServerError" KindLimitExceeded ErrKind = "LimitExceeded" KindStatusConflict ErrKind = "StatusConflict" KindDuplicateName ErrKind = "DuplicateName" KindInvalidId ErrKind = "InvalidId" KindNotAllowed ErrKind = "NotAllowed" KindServiceLocked ErrKind = "ServiceLocked" KindNotImplemented ErrKind = "NotImplemented" KindRangeNotSatisfiable ErrKind = "RangeNotSatisfiable" KindIOError ErrKind = "IOError" KindOverflowError ErrKind = "OverflowError" KindNaNError ErrKind = "NaNError" KindAuthenticationFailure ErrKind = "AuthenticationFailure" KindPayloadDecodeFailure ErrKind = "PayloadDecodeFailure" KindTimeout ErrKind = "Timeout" )
func Kind ¶
Kind determines the Kind associated with an error by inspecting the chain of errors. The first non-KindUnknown Kind found from the chain of wrappedErr is returned. If Kind cannot be determined from wrappedErr, KindUnknown is returned
func KindMapping ¶
KindMapping determines the correct error kind for the given HTTP response code.
type Error ¶
type Error interface { // Error obtains the error message associated with the error. Error() string // Message returns the first level error message without further details. Message() string // DebugMessages returns a detailed string for debug purpose. DebugMessages() string // Kind returns the error kind of this edge error. Kind() ErrKind // Details returns the detailed mapping associated with this edge error. Details() ErrDetails }
Error provides an abstraction for all internal errors. This exists so that we can use this type in our method signatures and return nil which will fit better with the way the Go builtin errors are normally handled.