Skip to content
/ errctx Public

Simple Go library for adding context to errors

License

Notifications You must be signed in to change notification settings

Ro5bert/errctx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

errctx

This package is worthless in Go 1.13. It was also worthless to begin with seeing as the popular pkg/errors has the same functionality.

errctx is a simple Go library for adding context (in the form of strings) to errors in situations when an error occurs and is propagated back through a long call chain; each function in the call chain may or may not want to add context as to where/why/how the error occurred.

errctx produces error strings of the following form:

<third piece of context>: <second piece of context>: <first piece of context>: <root error message>

Yes, it is essentially a glorified way of writing

err = fmt.Errorf("%s: %s", "context", err.Error())

only one has the option to get the root error (and thus check its type) via errctx.Root(err).

See the in-source documentation for details. There is also a contrived example to take a look at.

About

Simple Go library for adding context to errors

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages