errutil

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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 FlushSentry(timeout time.Duration) bool

func Handle

func Handle(ctx context.Context, err error, msg string)

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

func HandleHTTP(ctx context.Context, w http.ResponseWriter, err error, statusCode int)

HandleHTTP is Handle plus an HTTP error response.

func InitSentry

func InitSentry(cfg SentryConfig) error

func SentryHTTPMiddleware

func SentryHTTPMiddleware(next http.Handler) http.Handler

Types

type SentryConfig

type SentryConfig struct {
	DSN         string
	Environment string
	Release     string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL