Skip to content

Format your errors as error trees with stack traces. (Proof of concept dirty code)

License

Notifications You must be signed in to change notification settings

gabivlj/error-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rrors

A proof-of-concept Golang error library that renders your error stack trace as a tree. Similar to xerrors but with support to errors.Join.

See the tests folder to see sample renderings.

Is this ready?

This is a proof of concept and hacky code all around, I'm just testing the idea :)

Usage

This is at your own risk, code is not perfect, but the idea is wrapping errors and preserving the stacktrace like xerrors did, but also adaption to errors.Join from go 1.20

err := rrors.Errorf("some error: %w", errors.Join(...))
// prints tree with stacktrace
fmt.Println(err)

Untested things

  • rrors.Errorf("%w %w") ?
  • errors.Is(rrors.Errorf(...)) ?
  • errors.As(...)

Plans

Add ways to query an error tree like doing:

  • rerrs.CountErrors(err, os.ErrNotFound) // counts the number of ErrNotFound in the error tree
  • rerrs.AsMultiple[MyErrorType](err) // returns errors of this type in the error tree

About

Format your errors as error trees with stack traces. (Proof of concept dirty code)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages