Documentation ¶
Overview ¶
Package eloc provides tools to add a stack trace to errors so that their origin can be easily located.
Index ¶
- func At(err error) error
- func Errorf(format string, a ...any) error
- func FmtFrame(w io.Writer, err Error)
- func FmtShortStack(w io.Writer, err Error)
- func FmtStack(w io.Writer, err Error)
- func Frame(err error) runtime.Frame
- func New(text string) error
- func ParseEnv(s string) error
- func RecoverAs(err *error)
- func Ret[R any](v R, err error) (R, error)
- func Stack(err error, do func(*runtime.Frame) (cont bool))
- type Error
- type Formatter
- type FormatterFunc
- type ShortStack
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FmtShortStack ¶
func RecoverAs ¶
func RecoverAs(err *error)
Example (Error) ¶
err := testMustCall(errors.New("ERROR")) fmt.Println(err)
Output: ERROR @[eloc.testPanic enabled_test.go:63]
Example (ErrorStack) ¶
ErrorFmt = FormatterFunc(FmtShortStack) err := testMustCall(errors.New("ERROR")) fmt.Println(err)
Output: ERROR @[eloc.testPanic@enabled_test.go:63,68,94/run_example.go:63/example.go:44/testing.go:1927/_testmain.go:65/proc.go:267/asm_amd64.s:1650]
Example (String) ¶
err := testMustCall("STRING") fmt.Println(err)
Output: STRING @[eloc.testPanic enabled_test.go:63]
Types ¶
type Formatter ¶
var ( // Disabled allows to disable/enable all error location handling through // eloc. If this runtime switch is not enough one can also use the Go build // tag 'eloc_off' to remove eloc location handling during comiple time. In // that case setting Disabled has o effect. Disbaled atomic.Bool ErrorFmt Formatter = FormatterFunc(FmtShortStack) )
type FormatterFunc ¶
type ShortStack ¶
type ShortStack struct {
// contains filtered or unexported fields
}
func (*ShortStack) String ¶
func (s *ShortStack) String() string
Directories ¶
Path | Synopsis |
---|---|
Package must is an experiment to see if a concise way to work with panics will break Go's convention to explicitly check for errors as described in https://blog.golang.org/error-handling-and-go.
|
Package must is an experiment to see if a concise way to work with panics will break Go's convention to explicitly check for errors as described in https://blog.golang.org/error-handling-and-go. |
Click to show internal directories.
Click to hide internal directories.