5 ms·
There are several existing Go error libraries with a similar approach sans context. The approach I ended up taking is to use slog attributes. It allows for reu
by gregwebs 1y ago
There are several existing Go error libraries with a similar approach sans context.
The approach I ended up taking is to use slog attributes. It allows for reuse of existing logging attributes.
This is explained here (skip to the “adding metadata” portion). https://blog.gregweber.info/blog/go-errors-library/ https://blog.gregweber.info/blog/go-errors-library/
Go package: https://pkg.go.dev/github.com/gregwebs/errors/slogerr https://pkg.go.dev/github.com/gregwebs/errors/slogerr