fmts

package
v0.22.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAnonymouse = errors.New("error")

ErrAnonymouse represent errors that doesn't have source. see Errorf.

Functions

func Error

func Error(err error) error

Error wraps an error into a StructError, recording the stack trace and a default message.

func ErrorWith added in v0.22.0

func ErrorWith(format string, args ...any) error

ErrorWith formats according to a format specifier and returns the string as a value that satisfies error. ErrorWith also records the stack trace at the point it was called.

func Errorf

func Errorf(err error, format string, args ...any) error

Errorf wraps an error into a StructError, appending a formatted message. If the error is already a StructError, it appends the message to the existing one.

Types

type Frame added in v0.21.4

type Frame uintptr

Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.

func (Frame) Format added in v0.21.4

func (f Frame) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%s    source file
%d    source line
%n    function name
%v    equivalent to %s:%d

Format accepts flags that alter the printing of some verbs, as follows:

%+s   function name and path of source file relative to the compile time
      GOPATH separated by \n\t (<funcname>\n\t<path>)
%+v   equivalent to %+s:%d

func (Frame) MarshalText added in v0.21.4

func (f Frame) MarshalText() ([]byte, error)

MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.

type StackTrace added in v0.21.4

type StackTrace []Frame

StackTrace is stack of Frames from innermost (newest) to outermost (oldest).

func (StackTrace) Format added in v0.21.4

func (st StackTrace) Format(s fmt.State, verb rune)

Format formats the stack of Frames according to the fmt.Formatter interface.

%s	lists source files for each Frame in the stack
%v	lists the source file and line number for each Frame in the stack

Format accepts flags that alter the printing of some verbs, as follows:

%+v   Prints filename, function, and line number for each Frame in the stack.

type StructError added in v0.22.0

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

func (*StructError) Error added in v0.22.0

func (w *StructError) Error() string

func (*StructError) Format added in v0.22.0

func (w *StructError) Format(s fmt.State, verb rune)

func (*StructError) Message added in v0.22.0

func (w *StructError) Message() string

func (*StructError) Stack added in v0.22.0

func (w *StructError) Stack() StackTrace

func (StructError) StackTrace added in v0.22.0

func (s StructError) StackTrace() StackTrace

func (*StructError) Unwrap added in v0.22.0

func (w *StructError) Unwrap() error

Unwrap provides compatibility for Go 1.13 error chains.

Jump to

Keyboard shortcuts

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