gerror

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(err error) gcode.Code

Code returns the error code of current error. It returns CodeNil if it has no error code or it does not implements interface Code.

func New

func New(text string) error

New creates and returns an errors which is formatted from given text.

func NewCode

func NewCode(code gcode.Code, text ...string) error

NewCode creates and returns an errors that has errors code and given text.

func NewCodef

func NewCodef(code gcode.Code, format string, args ...interface{}) error

NewCodef returns an errors that has errors code and formats as the given format and args.

func Newf

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

Newf returns an errors that formats as the given format and args.

func WrapCode

func WrapCode(code gcode.Code, err error, text ...string) error

WrapCode wraps error with code and text. It returns nil if given err is nil.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is custom errors for additional features.

func (*Error) Cause

func (err *Error) Cause() error

Cause returns the root cause errors.

func (*Error) Code

func (err *Error) Code() gcode.Code

Code returns the errors code. It returns CodeNil if it has no errors code.

func (*Error) Current

func (err *Error) Current() error

Current creates and returns the current level errors. It returns nil if current level errors is nil.

func (*Error) Error

func (err *Error) Error() string

Error implements the interface of Error, it returns all the errors as string.

func (*Error) Format

func (err *Error) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%v, %s : Print all the errors string; %-v, %-s : Print current level errors string; %+s : Print full stack errors list; %+v : Print the errors string and full stack errors list;

func (*Error) MarshalJSON

func (err *Error) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal. Note that do not use pointer as its receiver here.

func (*Error) Next

func (err *Error) Next() error

Next returns the next level errors. It returns nil if current level errors or the next level errors is nil.

func (*Error) Stack

func (err *Error) Stack() string

Stack returns the stack callers as string. It returns an empty string if the <err> does not support stacks.

Jump to

Keyboard shortcuts

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