Documentation
¶
Overview ¶
Package errs provides error handling utilities that extend Go's standard "errors" library.
It offers:
- UnwrapDeep: recursively unwraps error chains until the root/deepest error is reached.
Usage:
import "github.com/amberpixels/k1/errs"
// Get the root cause of a wrapped error chain
rootErr := errs.UnwrapDeep(wrappedError)
// Example with error wrapping:
err1 := errors.New("root cause")
err2 := fmt.Errorf("layer 2: %w", err1)
err3 := fmt.Errorf("layer 3: %w", err2)
root := errs.UnwrapDeep(err3) // returns err1
Package errs is intended as a lightweight helper for deep error chain traversal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnwrapDeep ¶
UnwrapDeep recursively unwraps an error chain until it reaches the deepest/root error. It returns the root cause of the error chain, or nil if the input is nil.
Example:
err1 := errors.New("database connection failed")
err2 := fmt.Errorf("query failed: %w", err1)
err3 := fmt.Errorf("operation failed: %w", err2)
root := errs.UnwrapDeep(err3) // returns err1
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.