Documentation
¶
Index ¶
- type BaseError
- func (be BaseError) AddDetail(key string, detail any)
- func (be BaseError) Code() int
- func (be BaseError) DebugMessages() string
- func (be BaseError) Error() string
- func (be BaseError) Is(err error) bool
- func (be BaseError) Kind() string
- 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) Code ¶ added in v1.0.38
Code always returns 1 because BaseError is just a generic error that does not contain an error code. To get a specific error code, wrap BaseError using a more detailed error type, such as NewHTTPError.
func (BaseError) DebugMessages ¶
DebugMessages returns a string taking all nested and wrapped operations and errors into account.
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
func Details ¶ added in v1.0.35
func Details(err error) ErrDetails
Details extracts error details from the given error. If the error is not of type BaseError, it returns nil.
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