err_server

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: Apache-2.0, MIT Imports: 4 Imported by: 0

README

need generate

need kit https://pkg.go.dev/golang.org/x/tools/cmd/stringer

go install golang.org/x/tools/cmd/stringer@latest

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrJson

func ErrJson(code ErrCode) string

func ErrJsonf

func ErrJsonf(code ErrCode, format string, arg ...any) string

func Error

func Error(code ErrCode) error

func Errorf

func Errorf(code ErrCode, format string, arg ...any) error

func IsEqualCode

func IsEqualCode(err error, target ErrCode) bool

Types

type ErrCode

type ErrCode int

ErrCode error code

const (
	GoVersionError    ErrCode = 20000
	ConfigFormatError ErrCode = 20101

	RedisConnectError ErrCode = 20201

	DBConnectError    ErrCode = 20301
	DBInitializeError ErrCode = 20302
)

func (ErrCode) String

func (i ErrCode) String() string

type ServerError

type ServerError struct {
	Code    ErrCode `json:"code"`
	Message string  `json:"msg"`

	ServerErrorFunc ServerErrorFunc `json:"-"`
}

func (*ServerError) Error

func (e *ServerError) Error() string

func (*ServerError) Json

func (e *ServerError) Json() string

type ServerErrorFunc

type ServerErrorFunc interface {
	Json() string
}

Jump to

Keyboard shortcuts

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