errorchain

package
v1.34.0 Latest Latest
Warning

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

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

Documentation

Overview

Package errorchain provides dependency-free helpers for inspecting Go error chains. The package is public so extensions can preserve bounded diagnostic evidence across the azd gRPC boundary without depending on internal APIs.

Index

Constants

View Source
const MaxChainLen = 16

MaxChainLen caps the number of types collected from a single error chain. The cap bounds telemetry cardinality and protects traversal of pathological errors that unwrap to themselves.

Variables

This section is empty.

Functions

func CauseTypes

func CauseTypes(err error) []string

CauseTypes returns a bounded, de-duplicated list of useful local error types for transport across an extension boundary. Generic wrappers are omitted; type names use the format produced by reflect.Type.String.

func DeepestNamedType

func DeepestNamedType(err error) string

DeepestNamedType returns the deepest non-generic type name from the chain, skipping wrappers that do not identify an origin. It falls back to the leaf type when every entry is generic and returns "<nil>" for a nil error.

func DeepestNamedTypeFromTypes

func DeepestNamedTypeFromTypes(types []string) string

DeepestNamedTypeFromTypes returns the deepest useful type from a previously captured cause-type list. It returns "<nil>" when no type is available.

func IsGenericWrapper

func IsGenericWrapper(typeName string) bool

IsGenericWrapper reports whether typeName is a generic chain or UX wrapper.

func NormalizeCauseTypes

func NormalizeCauseTypes(types []string) []string

NormalizeCauseTypes bounds and de-duplicates diagnostic labels received from an extension. It returns a fresh slice and never includes generic wrappers. The normalized values remain extension-controlled and are not a privacy guarantee.

func SanitizeTypeName

func SanitizeTypeName(name string) string

SanitizeTypeName converts a Go type name into a telemetry-safe segment.

func Types

func Types(err error) []string

Types returns the wrapped-error type chain (outermost first) as a slice of Go type names. The traversal follows Unwrap() error linearly and walks Unwrap() []error depth-first in slice order. Nil children are skipped and the result is 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