safeerr

package
v0.3.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package safeerr classifies errors received across dependency boundaries without invoking caller-defined Is, As, or Unwrap methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assign

func Assign(root error, target any) (matched bool)

Assign stores the first error in root's bounded trusted graph that is assignable to the value addressed by target. It never invokes a custom As method. Invalid or nil targets simply do not match; callers using errors.As still receive that function's ordinary target validation before Assign is reached through an opaque boundary.

func Diagnostic

func Diagnostic(err error) string

Diagnostic returns err's diagnostic unless err is nil or typed nil. Nil values receive a stable opaque diagnostic without invoking any error method. A panic from a non-nil Error method is intentionally left to the caller's panic boundary.

func Find

func Find[T error](root error) (T, bool)

Find returns the first error in root's bounded trusted graph assignable to T.

func Is

func Is(root, target error) bool

Is reports whether root contains target. It compares error values directly, never invokes custom Is or As methods, and unwraps only standard-library or explicitly trusted framework error types. Traversal is bounded.

func Opaque

func Opaque(cause error) error

Opaque retains cause behind an errors.Is/errors.As-compatible boundary that never exposes cause through Unwrap. Standard inspection can match the raw cause, trusted nested sentinels, and assignable error types without invoking caller-defined Is, As, or Unwrap methods.

func Walk

func Walk(root error, visit func(error) bool) bool

Walk visits at most 64 errors in root's trusted unwrap graph. The visitor must not retain or mutate errors that are owned by another goroutine.

Types

This section is empty.

Jump to

Keyboard shortcuts

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