errcode

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Success             = _eg.CreateError(0, "success")
	UnknownError        = _eg.CreateError(1, "unknown")
	ParameterError      = _eg.CreateError(2, "parameter error")
	InternalError       = _eg.CreateError(3, "internal error")
	RepositoryInitError = _eg.CreateError(4, "repository init error")
)

Functions

func Must added in v0.2.8

func Must(err error, ec *Error) error

Must make sure error is an error code, if it is not an errcode, wrapper with ec, if it is an errcode, return itself, it is different from Wrap, which always wrapper with ec

func Wrap added in v0.2.8

func Wrap(err error, ec *Error) error

Wrap make sure error is an error code, if it is not an errcode, wrapper with ec if it is an errcode, wrap message with ec

Types

type Error

type Error struct {
	Code    int
	Message string
	Detail  string
}

Error struct for pb.Error

func CreateError

func CreateError(code int, msg string) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

Is implements errors.Is

func (*Error) WithDetail

func (e *Error) WithDetail(err error) *Error

func (*Error) WithDetailStr

func (e *Error) WithDetailStr(err string) *Error

func (*Error) WithDetailf added in v0.2.5

func (e *Error) WithDetailf(format string, a ...interface{}) *Error

func (*Error) Wrap added in v0.2.8

func (e *Error) Wrap(err error) error

Wrap make sure error is an error code, if it is not an errcode, wrapper with ec if it is an errcode, wrap message with ec same as Wrap

func (*Error) WrapIfNot added in v0.2.8

func (e *Error) WrapIfNot(err error) error

WrapIfNot make sure error is an error code, if it is not an errcode, wrapper with ec, if it is an errcode, return itself, same as Must

type ErrorGroup

type ErrorGroup struct {
	Code int
	Name string
}

func NewErrorGroup

func NewErrorGroup(groupCode int, name string) *ErrorGroup

func WithErrGroup

func WithErrGroup(groupCode int) *ErrorGroup

func (*ErrorGroup) CreateError

func (e *ErrorGroup) CreateError(code int, message string) *Error

func (*ErrorGroup) IsInGroup

func (e *ErrorGroup) IsInGroup(err error) bool

type UnmarshalError added in v0.3.2

type UnmarshalError struct {
	Error error
}

func (*UnmarshalError) UnmarshalJSON added in v0.3.2

func (ue *UnmarshalError) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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