Help us shape the future of Go! Take the 2026 Go Developer Survey

errctx

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package errctx carries a request-scoped sink that captures the original domain error behind a sanitized transport error.

The transport layer maps a domain error to a client-safe error (hiding SQL errors, stack traces, etc.) before returning it to the caller. That mapping discards the real cause, so a single request-logging interceptor could not otherwise record what actually failed. The sink bridges that gap: the mapper Captures the real error into a per-request sink, and the interceptor reads it back after the handler returns — one log line per request, with the true cause, without every layer logging its own copy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture

func Capture(ctx context.Context, err error)

Capture records err as the real error for the current request when a sink is present. It is a no-op if no sink was installed, so callers need not know whether they run inside a request.

func Captured

func Captured(ctx context.Context) error

Captured returns the real error recorded for the current request, or nil if none was captured (or no sink is installed).

func WithSink

func WithSink(ctx context.Context) context.Context

WithSink returns a context carrying a fresh error sink. The request-logging interceptor installs one at the start of every request.

Types

This section is empty.

Jump to

Keyboard shortcuts

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