Documentation
¶
Overview ¶
Package errors は、 error を操作する関数を提供する。
goのデフォルト error とともに、goのエラーで提供しないstack tracingのエラーも表示したいので、両方を出力できるようにしている。
"errors" + "github.com/pkg/errors"(スタックトレースのため) のwrapper。
stack情報をerrorに保存するためには、Wrap, Wrapfで errorにstack traceを含めるようにwrapして、
出力する側で %+v 形で表示する。
Index ¶
- func As(err error, target interface{}) bool
- func Errorf(format string, args ...interface{}) error
- func Is(err error, target error) bool
- func New(message string) error
- func Unwrap(err error) error
- func Wrap(err error, message string) error
- func Wrapf(err error, format string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶
As finds the first error in err's chain that matches the type to which target points, and if so, sets the target to its value and returns true. An error matches a type if it is assignable to the target type, or if it has a method As(interface{}) bool such that As(target) returns true. As will panic if target is not a non-nil pointer to a type which implements error or is of interface type.
The As method should set the target to its value and return true if err matches the type to which target points.
func Errorf ¶
Errorf formats according to a format specifier and returns the string as a value that satisfies error. Errorf also records the stack trace at the point it was called.
func Is ¶
Is reports whether any error in err's chain matches target.
An error is considered to match a target if it is equal to that target or if it implements a method Is(error) bool such that Is(target) returns true.
func New ¶
New returns an error with the supplied message. New also records the stack trace at the point it was called.
func Unwrap ¶
Unwrap returns the result of calling the Unwrap method on err, if err implements Unwrap. Otherwise, Unwrap returns nil.
Types ¶
This section is empty.