Documentation
¶
Overview ¶
Package errutil owns the project's non-fatal error reporting path. Every error that does not propagate further must end up here so it lands in both the structured log and (if configured) Sentry.
Index ¶
- Variables
- func FlushSentry(timeout time.Duration) bool
- func Handle(ctx context.Context, err error, msg string)
- func HandleHTTP(ctx context.Context, w http.ResponseWriter, err error, statusCode int)
- func InitSentry(cfg SentryConfig) error
- func SentryHTTPMiddleware(next http.Handler) http.Handler
- type SentryConfig
Constants ¶
This section is empty.
Variables ¶
var TagBenign = goerr.NewTag("benign")
TagBenign marks an error as a normal-flow occurrence: something that the code MUST handle (return 401, surface a validation message, etc.) but that is NOT an anomaly worth alerting on. Errors carrying this tag are logged at Info level and are not reported to Sentry by Handle / HandleHTTP.
Apply with goerr.T(errutil.TagBenign) at the call site that knows the error is benign. The tag is preserved across goerr.Wrap chains, so it is fine to tag deep in a usecase even if the outer layer wraps further.
Functions ¶
func FlushSentry ¶
func Handle ¶
Handle records a non-fatal error to the structured log and Sentry. The logger is taken from ctx so request-scoped fields propagate; goerr values are attached as both log attributes and Sentry context.
Errors tagged with TagBenign are demoted: they are logged at Info level and skipped by Sentry. This is the escape hatch for normal-flow conditions (e.g. missing auth cookie, expired token) that still need to flow through the error return value but should not page anyone.
func HandleHTTP ¶
HandleHTTP is Handle plus an HTTP error response.
func InitSentry ¶
func InitSentry(cfg SentryConfig) error