gerror

package
v1.13.3-0...-5aac4af Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package errors provides simple functions to manipulate errors.

Very note that, this package is quite a base package, which should not import extra packages except standard packages, to avoid cycle imports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause returns the root cause error of <err>.

func New

func New(text string) error

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

func NewSkip

func NewSkip(skip int, text string) error

NewSkip creates and returns an error which is formatted from given text. The parameter <skip> specifies the stack callers skipped amount.

func Newf

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

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

func NewfSkip

func NewfSkip(skip int, format string, args ...interface{}) error

NewfSkip returns an error that formats as the given format and args. The parameter <skip> specifies the stack callers skipped amount.

func Stack

func Stack(err error) string

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

func Wrap

func Wrap(err error, text string) error

Wrap wraps error with text. It returns nil if given err is nil.

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. It returns nil if given <err> is nil.

Types

type ApiCause

type ApiCause interface {
	Error() string // It should be en error.
	Cause() error
}

ApiCause is the interface for Cause feature.

type ApiStack

type ApiStack interface {
	Error() string // It should be en error.
	Stack() string
}

ApiStack is the interface for Stack feature.

type Error

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

Error is custom error for additional features.

func (*Error) Cause

func (err *Error) Cause() error

Cause returns the root cause error.

func (*Error) Error

func (err *Error) Error() string

Error implements the interface of Error, it returns the error 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 the error string; %-v, %-s : Print current error string; %+s : Print full stack error list; %+v : Print the error string and full stack error list;

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