errorx

package
v0.0.0-...-840d798 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorWithoutStack

func ErrorWithoutStack(err error) string

func New

func New(format string, args ...any) error

func NewByCode

func NewByCode(code int32, options ...Option) error

NewByCode get an error predefined in the configuration file by statusCode with a stack trace at the point NewByCode is called.

func WrapByCode

func WrapByCode(err error, statusCode int32, options ...Option) error

WrapByCode returns an error annotating err with a stack trace at the point WrapByCode is called, and the status code.

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Wrapf returns an error annotating err with a stack trace at the point Wrapf is called, and the format specifier.

Types

type Option

type Option = internal.Option

Option is used to configure an StatusError.

func WithExtra

func WithExtra(extra map[string]string) Option

WithExtra set extra for StatusError.

func WithExtraMsg

func WithExtraMsg(msg string) Option

func WithMsgParam

func WithMsgParam(k, v string) Option

type StatusError

type StatusError interface {
	error
	Code() int32
	Extra() map[string]string
	WithExtra(map[string]string)
}

StatusError is an interface for error with status code, you can create an error through NewByCode or WrapByCode and convert it back to StatusError through FromStatusError to obtain information such as error status code.

func FromStatusError

func FromStatusError(err error) (statusErr StatusError, ok bool)

FromStatusError converts err to StatusError.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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