errorx

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// 0-999 reserved
	CodeSuccess = 0
	CodeFailed  = 1
	CodeSystem  = 2
)

Variables

View Source
var Messages = map[int]string{

	CodeSuccess: "success",
	CodeFailed:  "failed",
	CodeSystem:  "system error",
}

Functions

func GetMessage

func GetMessage(code int, lang ...string) string

func ToSystemError

func ToSystemError(err error) error

ToSystemError if not Error, to system error

func WithStack

func WithStack(err error) error

Types

type Error

type Error struct {
	Code    int      `json:"code" xml:"code"`
	Message string   `json:"message" xml:"message"`
	Stack   []string `json:"-" xml:"-"`
}

func NewError

func NewError(code int, msg string) Error

func (Error) CodeMsg

func (e Error) CodeMsg() (int, string)

func (Error) Error

func (e Error) Error() string

func (Error) MultiErr

func (e Error) MultiErr(err error) Error

func (Error) MultiMsg

func (e Error) MultiMsg(v ...interface{}) Error

Jump to

Keyboard shortcuts

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