Documentation
¶
Overview ¶
Package errverbose provides utilities to manage error verbose messages.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Formatter ¶
Formatter returns a fmt.Formatter that writes the error's verbose message.
Example ¶
err := errbase.New("error")
f := Formatter(err)
fmt.Println(f)
Output: error
func String ¶
String returns the error's verbose message as a string.
Example ¶
err := errbase.New("error")
s := String(err)
fmt.Println(s)
Output: error
func Write ¶
Write writes the error's verbose message to the writer.
The first line is the error's message. The following lines are the verbose message of the error chain.
Example ¶
err := errbase.New("error")
buf := new(strings.Builder)
Write(buf, err)
s := buf.String()
fmt.Println(s)
Output: error
Types ¶
type AppendInterface ¶ added in v0.17.1
AppendInterface is an interface that can be implemented by error types that want to provide a custom verbose error message when appended to a byte slice.
It is an alternative to Interface that appends the verbose message directly to the destination byte slice. This avoids the intermediate string allocation of Interface, which is beneficial for performance.
type Interface ¶
type Interface interface {
error
// ErrorVerbose returns the error verbose message.
// It must only return the verbose message of the error, not the error chain.
// It must not end with a newline.
ErrorVerbose() string
}
Interface is an error that provides verbose information.
It is used by Write.
AppendInterface is an alternative that appends the verbose message to a byte slice instead of returning a string, avoiding the string allocation.