errchain

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errchain provides low-level, dependency-free helpers for inspecting Go error chains. It is intentionally separate from the classifier in internal/cmd so telemetry sub-spans in low-level packages can emit chain context without pulling in the full typed classifier graph.

Index

Constants

View Source
const MaxChainLen = 16

MaxChainLen caps the number of types collected from a single error chain. The cap is global to bound telemetry cardinality and to stop pathological errors that unwrap to themselves.

Variables

This section is empty.

Functions

func DeepestNamedType

func DeepestNamedType(err error) string

DeepestNamedType returns the deepest non-generic type name from the chain, skipping the wrappers in genericWrappers so a fmt.Errorf or suggestion wrap doesn't mask the real error. Falls back to the leaf type when nothing in the chain is non-generic. Returns "<nil>" for a nil error.

func IsGenericWrapper

func IsGenericWrapper(typeName string) bool

IsGenericWrapper reports whether the given Go type name (as produced by reflect.TypeOf(err).String()) is a generic chain wrapper. Exposed so the typed classifier in internal/cmd can apply the same logic when picking a fallback ResultCode.

func SanitizeTypeName

func SanitizeTypeName(name string) string

SanitizeTypeName converts a Go type name (e.g. "*azcore.ResponseError") into a telemetry-safe segment ("azcore_ResponseError").

func Types

func Types(err error) []string

Types returns the wrapped-error type chain (outermost first) as a slice of Go type names (e.g. "*fmt.wrapError", "*azcore.ResponseError"). The traversal:

  • follows Unwrap() error linearly,
  • depth-first walks Unwrap() []error in slice order,
  • skips nil children,
  • is globally capped at MaxChainLen.

Returns nil for a nil error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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