errs

package
v0.0.49-alpha.31 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 96

Documentation

Index

Constants

View Source
const (
	// General error codes.
	ServerInternalError = 500  // Server internal error
	ArgsError           = 1001 // Input parameter error
	NoPermissionError   = 1002 // Insufficient permission
	DuplicateKeyError   = 1003
	RecordNotFoundError = 1004 // Record does not exist

	TokenExpiredError     = 1501
	TokenMalformedError   = 1503
	TokenNotValidYetError = 1504
	TokenUnknownError     = 1505
)

Variables

View Source
var (
	ErrArgs             = NewCodeError(ArgsError, "ArgsError")
	ErrNoPermission     = NewCodeError(NoPermissionError, "NoPermissionError")
	ErrInternalServer   = NewCodeError(ServerInternalError, "ServerInternalError")
	ErrRecordNotFound   = NewCodeError(RecordNotFoundError, "RecordNotFoundError")
	ErrDuplicateKey     = NewCodeError(DuplicateKeyError, "DuplicateKeyError")
	ErrTokenMalformed   = NewCodeError(TokenMalformedError, "TokenMalformedError")     //
	ErrTokenNotValidYet = NewCodeError(TokenNotValidYetError, "TokenNotValidYetError") //
	ErrTokenUnknown     = NewCodeError(TokenUnknownError, "TokenUnknownError")
	ErrTokenExpired     = NewCodeError(TokenExpiredError, "TokenExpiredError")
)
View Source
var DefaultCodeRelation = newCodeRelation()

Functions

func Unwrap

func Unwrap(err error) error

func Wrap

func Wrap(err error) error

func WrapMsg

func WrapMsg(err error, msg string, kv ...any) error

Types

type CodeError

type CodeError interface {
	Code() int
	Msg() string
	Detail() string
	WithDetail(detail string) CodeError
	Error
}

func NewCodeError

func NewCodeError(code int, msg string) CodeError

type CodeRelation added in v0.0.47

type CodeRelation interface {
	Add(codes ...int) error
	Is(parent, child int) bool
}

type Error

type Error interface {
	Is(err error) bool
	Wrap() error
	WrapMsg(msg string, kv ...any) error
	error
}

func New

func New(s string, kv ...any) Error

Jump to

Keyboard shortcuts

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