Hacker News new | ask | show | jobs
by gregwebs 381 days 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/

Go package: https://pkg.go.dev/github.com/gregwebs/errors/slogerr