A Go library for structured, composable error handling with extensible decorators and metadata annotation.
Fault is a Go library designed for structured and composable error handling. It provides an extensible mechanism for wrapping errors using decorator functions, allowing developers to annotate errors with metadata, separate messages for developers and end-users, and categorize errors for easier handling. It solves the problem of verbose and awkward error composition in Go by offering a clean, modular approach.
Go developers building applications that require robust error handling, structured logging, and better diagnostics, especially in large-scale systems where error context and traceability are critical.
Developers choose Fault for its composable decorator pattern, which simplifies error annotation and integration with existing tools, and its focus on structured metadata over string concatenation, making it ideal for modern logging and debugging workflows.
Go errors but structured and composable. Fault provides an extensible yet ergonomic mechanism for wrapping 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.
Errors can be annotated with key-value pairs via fctx, enabling seamless integration with structured logging tools and better diagnostics, as shown in the logging example with trace IDs and user IDs.
Allows wrapping errors with multiple utilities like fmsg, fctx, and ftag in a single fault.Wrap call, making error composition clean and readable without nested function calls.
fmsg.WithDesc provides distinct messages for developers and end-users, improving user experience and debugging, with GetIssue concatenating user messages for clear output.
fctx attaches context metadata to errors, ensuring traceability across call stacks, which is essential for logging in large-scale applications, as demonstrated with request-specific data.
Compared to simple error wrapping with fmt.Errorf, Fault requires more boilerplate code, especially when using multiple decorators, which can increase code verbosity.
To leverage all features, developers must import and manage multiple subpackages (e.g., fmsg, fctx, ftag), complicating dependency management and setup.
As a newer library, Fault has fewer third-party integrations and community resources compared to established alternatives like pkg/errors or cockroachdb/errors.