Error context library with support for type-erased sources and backtraces,
targeting full support of all features on stable Rust, and with an eye towards
serializing runtime errors using serde
.
anomaly.rs draws inspiration from libraries like [error-chain
],
[failure
], and [anyhow
] to provide the following features:
anomaly::Context
] type which impls [std::error::Error
] including
support for type-erased [anomaly::BoxError
] sources. Contexts are generic
around an error Kind
, making the sources optional, and generally trying
to strike a balance between typed errors and Box
-based type erasure.anomaly::Message
] type, with a set
of macros to construct these errors.backtrace
] crate, and with it support for
stable Rust where other libraries might require nightly.serde
, allowing them
to be submitted to exception reporting services.Notably anomaly.rs does NOT include any sort of proc macro to define
its error Kind
type. We recommend [thiserror
] for that purpose.
[anomaly::Context
] is generic around a concrete Kind
type, and only
uses type erasure (based on [std::error::Error
]) when constructing
error chains:
std::error::Error
anomaly::Message
] for where enum variants are too
cumbersome or error messages are coming from e.g. API responses.anomaly.rs is an extraction of a set of patterns and boilerplate from real-world libraries and applications, most notably [Abscissa].
Copyright © 2019 iqlusion
anomaly.rs is distributed under the terms of either the MIT license or the Apache License (Version 2.0), at your option.
See [LICENSE] (Apache License, Version 2.0) file in the iqlusioninc/crates
toplevel directory of this repository or [LICENSE-MIT] for details.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.