errverbose

package
v0.17.4 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 7 Imported by: 2

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

func Formatter(err error) fmt.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

func String(err error) 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

func Write(w io.Writer, err error)

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

type AppendInterface interface {
	error
	ErrorVerboseAppend(b []byte) []byte
}

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.

Jump to

Keyboard shortcuts

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