Documentation
¶
Index ¶
- func As(err error, target any) bool
- func Caller() string
- func Callers() []string
- func Code(err error, defaultCode int32) int32
- func CodeMessage(err error, defaultCode int32, defaultMessage string, args ...any) (int32, string)
- func Is(err, target error) bool
- func Join(errs ...error) error
- func Match(err error, code int32) bool
- func MatchBadRequest(err error) bool
- func MatchForbidden(err error) bool
- func MatchNotFound(err error) bool
- func MatchRequireLogin(err error) bool
- func Message(err error, defaultMessage string, args ...any) string
- func New(text string) error
- func Unwrap(err error) error
- type Error
- func (e *Error) Args() map[string]any
- func (e *Error) Code() int32
- func (e *Error) Error() string
- func (e *Error) Message() string
- func (e *Error) String() string
- func (e *Error) Unwrap() error
- func (e *Error) With(err error) *Error
- func (e *Error) WithArgs(args ...any) *Error
- func (e *Error) WithCaller() *Error
- func (e *Error) WithCallers() *Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Code ¶ added in v0.3.0
Code unwraps error and gets code of it. It returns 0 if err is nil. It returns defaultCode if err doesn't have a code.
func CodeMessage ¶ added in v0.7.0
CodeMessage unwraps error and gets code & message of it. It returns 0 & "" if err is nil. It returns defaultCode if err doesn't have a code. It returns defaultMessage if err doesn't have a message.
func MatchBadRequest ¶ added in v0.7.0
MatchBadRequest matches err with bad request code.
func MatchForbidden ¶ added in v0.7.0
MatchForbidden matches err with forbidden code.
func MatchNotFound ¶ added in v0.7.0
MatchNotFound matches err with not found code.
func MatchRequireLogin ¶ added in v0.7.0
MatchRequireLogin matches err with require login code.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func BadRequest ¶ added in v0.0.3
BadRequest returns *Error with bad request code.
func RequireLogin ¶ added in v0.7.0
RequireLogin returns *Error with require login code.
func (*Error) WithCaller ¶ added in v0.7.0
WithCaller carries the top caller for *Error.
func (*Error) WithCallers ¶ added in v0.7.0
WithCallers carries all callers for *Error.