A Go error library providing network portability for error objects, suitable for distributed systems with mixed-version compatibility.
cockroachdb/errors is a comprehensive Go error handling library designed as a drop-in replacement for Go's standard errors package and github.com/pkg/errors. It uniquely enables error objects to be transparently encoded, transmitted over networks, and decoded while preserving their identity and structure, making it ideal for distributed systems. The library also provides native support for PII-free error reporting and integration with Sentry.io.
Go developers building distributed systems, microservices, or any application requiring error propagation across network boundaries, especially those needing to maintain error identity and structure after transmission. It's also suitable for teams requiring strict PII handling in error reporting.
Developers choose cockroachdb/errors over alternatives because it provides network portability for errors—errors can be encoded to protobuf, sent over a network, and decoded while remaining recognizable via errors.Is(). It uniquely supports forward compatibility for unknown error types and offers built-in PII stripping and Sentry.io integration, which are critical for production distributed systems.
Go error library with error portability over the network
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Errors can be encoded to protobuf, transmitted over networks, and decoded while preserving identity for errors.Is() checks, enabling reliable error handling in distributed systems as highlighted in the README's feature table.
Provides native support for stripping personally identifiable information from error details, with opt-in safe string reporting via errors.Safe() and automatic PII-free Sentry reports, crucial for compliance.
Offers automatic error reporting to Sentry.io with formatted, PII-stripped details through errors.ReportError(), reducing setup time for production monitoring.
Includes a wide array of wrapper constructors for hints, details, stack traces, secondary errors, and telemetry keys, allowing expressive error handling as detailed in the Available wrapper constructors section.
Supports mixed-version deployments by recognizing errors after network transmission even with unknown types, ensuring resilience in evolving systems.
The plethora of constructors and features, such as custom encoder/decoder registration and multiple wrapper types, can overwhelm developers accustomed to simpler error handling, leading to a steeper learning curve.
Network portability relies on gogoproto for encoding, adding an external dependency that might not be desirable in lightweight or dependency-averse Go projects.
Creating and registering custom error types requires additional steps like implementing Format() and SafeFormatter, and calling errors.RegisterTypeMigration() for renames, which adds development overhead.
Features like automatic stack trace capture and protobuf encoding introduce performance overhead compared to standard errors, which might be negligible but is a trade-off for richer functionality.