A lightweight Go library merging standard library errors and github.com/pkg/errors with enhanced features like stack traces and error matching.
Emperror/errors is a comprehensive error handling library for Go that serves as a drop-in replacement for both the standard library errors package and github.com/pkg/errors. It combines their functionality while adding modern features like structured error details and flexible error matching, making error management more robust and developer-friendly.
Go developers building applications that require advanced error handling, such as those needing stack traces, error wrapping, multi-error aggregation, or structured error details. It is particularly useful for teams transitioning between or unifying different error handling approaches in Go.
Developers choose Emperror/errors because it unifies and extends Go's error handling capabilities in a single, lightweight library, offering compatibility with existing standards while providing enhanced features like structured details and error matching that simplify debugging and error management.
Drop-in replacement for the standard library errors package and github.com/pkg/errors
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides New, Unwrap, Is, and As functions with stack trace support, backporting Go 1.13 features for older versions, ensuring seamless integration with existing code.
Includes Errorf, WithMessage, WithStack, Wrap, and Cause functions that match the original library's behavior, making migration from github.com/pkg/errors straightforward.
Allows attaching key-value pairs with WithDetails functions, enabling richer error context for debugging and logging, as demonstrated in the README examples.
Supports aggregating multiple errors into a single value, simplifying error handling in complex operations like batch processing or concurrent tasks.
Introduces an external library dependency, which may be a concern for projects aiming for minimal dependencies or those in regulated environments with compliance requirements.
Stack trace generation and error wrapping add runtime overhead and increased memory usage compared to plain error creation, potentially impacting performance-critical applications.
While a drop-in replacement, additional features like structured details and the match package require learning new APIs, which can slow down adoption and increase cognitive load for teams.