Documentation ¶
Index ¶
- Variables
- type Error
- func AsLakeErrorType(err error) Error
- func Convert(err error) Error
- func Convert00001[T1 any, T2 any, T3 any, T4 any](t1 T1, t2 T2, t3 T3, t4 T4, err error) (T1, T2, T3, T4, Error)
- func Convert0001[T1 any, T2 any, T3 any](t1 T1, t2 T2, t3 T3, err error) (T1, T2, T3, Error)
- func Convert001[T1 any, T2 any](t1 T1, t2 T2, err error) (T1, T2, Error)
- func Convert01[T1 any](t1 T1, err error) (T1, Error)
- type MessageType
- type Messages
- type Option
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // Default special error type. If it's wrapping another error, then it will take the type of that error if it's an Error. Otherwise, it equates to Internal. Default = register(nil) SubtaskErr = register(&Type{meta: "subtask"}) NotFound = register(&Type{httpCode: http.StatusNotFound, meta: "not-found"}) BadInput = register(&Type{httpCode: http.StatusBadRequest, meta: "bad-input"}) Forbidden = register(&Type{httpCode: http.StatusForbidden, meta: "forbidden"}) Internal = register(&Type{httpCode: http.StatusInternalServerError, meta: "internal"}) Timeout = register(&Type{httpCode: http.StatusGatewayTimeout, meta: "timeout"}) )
Supported error types
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error interface { // Messages the message associated with this Error. Messages() Messages // GetType gets the Type of this error GetType() *Type // As Attempts to cast this Error to the requested Type, and returns nil if it can't. As(*Type) Error // GetData returns the data associated with this Error (may be nil) GetData() interface{} // contains filtered or unexported methods }
Error The interface that all internally managed errors should adhere to.
func AsLakeErrorType ¶ added in v0.14.0
AsLakeErrorType attempts to cast err to Error, otherwise returns nil
func Convert ¶ added in v0.14.0
Convert converts a raw error to an Error. Similar to Type.WrapRaw with a type of Default, but will not wrap the error if it's already of type Error. Passing in nil will return nil.
func Convert00001 ¶ added in v0.14.0
func Convert00001[T1 any, T2 any, T3 any, T4 any](t1 T1, t2 T2, t3 T3, t4 T4, err error) (T1, T2, T3, T4, Error)
Convert00001 like Convert01, but with four extra args
func Convert0001 ¶ added in v0.14.0
Convert0001 like Convert01, but with three extra args
func Convert001 ¶ added in v0.14.0
Convert001 like Convert01, but with two extra args
type MessageType ¶ added in v0.14.0
type MessageType int
MessageType the type of message for an Error
type Messages ¶ added in v0.14.0
type Messages []*errMessage
Messages alias for messages of an Error
func (Messages) Causes ¶ added in v0.14.0
Causes gets the non-main messages of the Messages in causal sequence
type Option ¶ added in v0.14.0
type Option func(*options)
Option add customized properties to the Error
type Type ¶ added in v0.14.0
type Type struct {
// contains filtered or unexported fields
}
Type error are constructed from these, and they contain metadata about them.
func HttpStatus ¶ added in v0.14.0
func (*Type) Combine ¶ added in v0.14.0
Combine constructs a new Error from combining multiple errors. Stacktrace info for each of the errors will not be present in the result, so it's best to log the errors before combining them.
func (*Type) GetHttpCode ¶ added in v0.14.0
GetHttpCode gets the associated Http code with this Type, if explicitly set, otherwise http.StatusInternalServerError
func (*Type) Wrap ¶ added in v0.14.0
Wrap constructs a new Error instance with this message and wraps the passed in error. A nil 'err' will return a nil Error.