#backtrace #error-handling #serde #exception-reporting

no-std anomaly

Error context library with support for type-erased sources and backtraces

2 unstable releases

0.2.0 Feb 4, 2020
0.1.2 Jan 13, 2020
0.1.1 Jan 1, 2020
0.1.0 Jan 1, 2020
0.0.0 Aug 30, 2019

#173 in Rust patterns

Download history 1280/week @ 2021-02-26 834/week @ 2021-03-05 1245/week @ 2021-03-12 1802/week @ 2021-03-19 1421/week @ 2021-03-26 1678/week @ 2021-04-02 1901/week @ 2021-04-09 1522/week @ 2021-04-16 964/week @ 2021-04-23 2067/week @ 2021-04-30 1423/week @ 2021-05-07 1461/week @ 2021-05-14 2029/week @ 2021-05-21 2133/week @ 2021-05-28 2669/week @ 2021-06-04 2554/week @ 2021-06-11

6,225 downloads per month
Used in 31 crates (11 directly)

Apache-2.0 OR MIT

239 lines

anomaly.rs 🦠 iqlusion

Crate Docs Apache 2.0/MIT Licensed MSRV Safety Dance Build Status Gitter Chat

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:

  • An 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.
  • Stringly typed errors using the anomaly::Message type, with a set of macros to construct these errors.
  • Backtrace support using the backtrace crate, and with it support for stable Rust where other libraries might require nightly.
  • Support for serializing errors using serde, allowing them to be submitted to exception reporting services and other structured logging systems.

Notably anomaly.rs does NOT include any sort of proc macro to define its error Kind type. We recommend thiserror for that purpose.

What makes anomaly.rs different?

anomaly::Context and its Box-ed wrapper, anomaly::Error, are generic around a concrete Kind type. Type erasure (based on std::error::Error) is only used when constructing error chains:

  • Concrete (generic) types for immediate errors
  • Type erasure for error sources
  • No additional traits beyond std::error::Error
  • Stringly typed anomaly::Message for where enum variants are too cumbersome or error messages are coming from e.g. API responses.
  • Structured logging of your errors using serde


anomaly.rs is an extraction of a set of patterns and boilerplate from real-world libraries and applications, most notably Abscissa.


  • Rust 1.38+


Copyright © 2019-2020 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.


~74K SLoC