errors

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StoreSvcBaseErrorCode panic
	StoreSvcBaseErrorCode = 10000
	// GeneratorSvcBaseErrCode generator error code
	GeneratorSvcBaseErrCode = 20000
	// TenantSvcBaseErrCode tenant error code
	TenantSvcBaseErrCode = 30000
	// AdminSvcBaseErrCode admin error code
	AdminSvcBaseErrCode = 40000
)

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

As panics if target is not a non-nil pointer to either a type that implements error, or to any interface type.

func CheckErrorCode

func CheckErrorCode(errCode int32) bool

CheckErrorCode 判断错误码是否是成功错误吗

func Is

func Is(err, target error) bool

Is reports whether any error in err's chain matches target.

func New

func New(text string) error

New returns an error that formats as the given text. Each call to New returns a distinct error value even if the text is identical.

func Unwrap

func Unwrap(err error) error

Unwrap returns the result of calling the Unwrap method on err, if err's type contains an Unwrap method returning error. Otherwise, Unwrap returns nil.

Types

type ErrCode

type ErrCode int32

ErrCode 错误码类型

const (
	// GeneratorSvcParamsInvalid generator参数校验失败
	GeneratorSvcParamsInvalid ErrCode = iota + GeneratorSvcBaseErrCode
	GeneratorSvcOperateDBFailed
	GeneratorSvcRecordIsExist
	GeneratorSvcRecordNotFound
	GeneratorSvcObjectIDInvalid
)
const (
	// TenantSvcParamsInvalid tenant参数校验失败
	TenantSvcParamsInvalid ErrCode = iota + TenantSvcBaseErrCode
	// TenantSvcOperateDBFailed tenant数据库操作失败
	TenantSvcOperateDBFailed
	TenantSvcRecordIsExist
	TenantSvcRecordNotFound
	TenantSvcObjectIDInvalid
	TenantSvcGetAuthTokenFailed
	TenantSvcAccessTokenParseFailed
)
const (
	// AdminSvcParamsInvalid admin参数校验失败
	AdminSvcParamsInvalid ErrCode = iota + AdminSvcBaseErrCode
	// AdminSvcUnauthorized admin登录失败
	AdminSvcUnauthorized
	// AdminSvcOperateDBFailed admin数据库操作失败
	AdminSvcOperateDBFailed
	// AdminSvcForbidden admin鉴权失败
	AdminSvcForbidden
	// AdminSvcRecordIsExist admin记录已经存在
	AdminSvcRecordIsExist
	// AdminSvcDeleteRecordNotExist admin删除的记录不存在
	AdminSvcDeleteRecordNotExist
)
const (
	// SUCCESS 约定成功为 0
	SUCCESS ErrCode = 0
)
const (
	// StoreSvcOperateAdapterFailed store适配器操作失败
	StoreSvcOperateAdapterFailed ErrCode = iota + StoreSvcBaseErrorCode
)

func (ErrCode) Code

func (e ErrCode) Code() int32

Code 返回错误码

func (ErrCode) String

func (i ErrCode) String() string

Jump to

Keyboard shortcuts

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