4 releases

new 0.3.0 May 13, 2024
0.2.0 May 9, 2024
0.2.0-beta May 1, 2024
0.2.0-alpha Apr 26, 2024
0.1.0 Sep 17, 2019

#196 in Debugging

Download history 7/week @ 2024-02-19 17/week @ 2024-02-26 8/week @ 2024-03-04 14/week @ 2024-03-11 9/week @ 2024-03-18 5/week @ 2024-03-25 35/week @ 2024-04-01 5/week @ 2024-04-08 1/week @ 2024-04-15 135/week @ 2024-04-22 144/week @ 2024-04-29 146/week @ 2024-05-06

427 downloads per month
Used in spritec

MIT/Apache

52KB
1.5K SLoC

terminator

Rust library to provide fancy formatting for errors and backtraces. Based of and inspired by color-eyre. It is intended to be used in binary applications, not as error type in libraries.

Usage

To display pretty errors from your main function, you can just switch your error type to terminator::Terminator. However, to customise the appearance and behaviour of errors or to pretty print panics, set up your main function as below:

fn main() -> Result<(), terminator::Terminator> {
    terminator::Config::new()
        // modify config if you so wish
        // and install config (setting up panic hook)
        .install()?;

    Ok(())
}

Feature flags

Terminator can bundle support for common error trait object libraries like anyhow and eyre. Setting respective flags will enable conversions and ? operator for Terminator. By default, Terminator is backed by Box<dyn Error>.

Following flags are provided:

  • anyhow: use anyhow::Error as backend for Terminator (conflicts with eyre feature)
  • eyre: use eyre::Report as backend for Terminator (conflicts with anyhow feature)
  • compat: enable Compat struct as bridge between eyre and anyhow if both are used

Appearance

By default, Terminator should look like the following (you should see colors)

Error:
   0: alright, I'm done, show yourself out with pretty formatting and a fancy backtrace
   1: it is pretty nasty, let's send it back to caller
   2: an error is never late, nor is it early, it arrives precisely when it means to
   3: wild error has appeared

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 2 frames hidden ⋮
   2: example::module::function
      at ./src/example.rs:25
   3: core::ops::function::FnOnce::call_once
      at /rustc/hash/library/core/src/ops/function.rs:250
   4: <F as example::Eval<A>>::eval
      at ./src/lib.rs:20
   5: example::main
      at ./src/main.rs:25
   6: core::ops::function::FnOnce::call_once
      at /rustc/hash/library/core/src/ops/function.rs:250
                                ⋮ 15 frames hidden ⋮

Dependencies

~70KB