Documentation
¶
Index ¶
Constants ¶
View Source
const ( // Suffix adds caller information at the end of the error message. // This is default. Suffix callerOption = iota // Prefix adds caller information at the beginning of the error message. Prefix // Disabled does not include caller information in the error message. Disabled )
View Source
const ( // Newline joins errors with \n. // This is default. Newline layoutOption = iota // Inline wraps errors with ↩. Inline )
View Source
const ( // Trim current working directory from filenames. TrimCWD trimCWDOption = true )
View Source
const ( // Include stacktrace in error message. WithStack withStackTraceOption = true )
Variables ¶
View Source
var ( // TrimPrefixes from caller frame filenames. TrimPrefixes = func(prefixes ...string) trimPrefixesOption { return trimPrefixesOption{prefixes: prefixes} } )
Functions ¶
Types ¶
type Err ¶
type Err string
Err string type.
To include runtime caller information on the error, one of the Err methods, other than Error(), must be called.
For examples see the example tests. All examples demonstrate using exported errors as a recommended best practice because exported errors enable unit-tests that assert expected errors such as: assert.ErrorIs(t, err, ErrProcessThing).
func (Err) Errorf ¶
Errorf returns an error using Err formatted as text. Use Errorf if your Err string itself contains fmt format specifiers.
var ErrProcessThing errific.Err = "error processing thing id: '%s'" return ErrProcessThing.Errorf("abc")
func (Err) New ¶
New returns an error using Err as text with errors joined.
var ErrProcessThing errific.Err = "error processing a thing" return ErrProcessThing.New(err)
Click to show internal directories.
Click to hide internal directories.