A comprehensive Go library for expressive error handling with stack traces, composability, and type/trait checks.
Errorx is a Go library that provides a robust toolset for creating, enhancing, and managing errors. It addresses limitations in conventional Go error handling by emphasizing debug information, type safety, and composability while maintaining performance and simplicity.
Go developers building applications that require detailed error debugging, type-safe error differentiation, and composable error handling patterns.
Developers choose Errorx for its automatic stack traces, type and trait-based error checks, and non-intrusive error decoration, offering a balance of debug readiness and performance over naive implementations.
A comprehensive error handling library for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Includes stack traces by default for better debugging, with benchmarks showing it's 100x cheaper than naive debug.Stack() implementations, as detailed in the performance section.
Enables robust error identification via IsOfType and HasTrait checks, avoiding unreliable string matching on error messages, demonstrated in the error check examples.
Provides Decorate and Wrap functions to add contextual information without altering original error properties, preserving composability and stack traces.
Offers modifiers like TypeModifierOmitStackTrace to control overhead, with benchmarks guiding when to skip traces for optimal performance in real-world scenarios.
Collecting stack traces can cause up to 10x slowdown in error creation and another 10x in formatting, as admitted in benchmarks, which may impact hot code paths or frequent error returns.
Introduces abstractions like error types, traits, namespaces, and modifiers, increasing the learning curve compared to standard Go error handling, especially for teams new to such patterns.
Adopting Errorx's error types and traits can make it harder to switch to other error libraries or integrate with tools expecting standard error interfaces, creating vendor lock-in.