Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ our more experienced community members will be happy to help.

You can improve Eyre's ecosystem by building your own
[EyreHandler](https://docs.rs/eyre/0.6.8/eyre/trait.EyreHandler.html) crates
like [color-eyre](https://github.com/eyre-rs/color-eyre/). The customizable
like [color-eyre](https://github.com/eyre-rs/eyre/tree/master/color-eyre/). The customizable
reporting of `eyre` is it's secret sauce, using that customizability in
creative ways and sharing your work is one of the best ways you can inspire
others and help grow our community.
Expand Down Expand Up @@ -164,8 +164,7 @@ There are three main places you can check for things to review:

1. Pull request which are ready and in need of more reviews on
[eyre](https://github.com/eyre-rs/eyre/pulls?q=is%3Aopen+is%3Apr+-label%3AS-Ready-For-Final-Review+-draft%3A%3Atrue+-label%3AS-Needs-RFC+-reviewed-by%3A%40me+-author%3A%40me)
2. Pull requests on [eyre](https://github.com/eyre-rs/eyre/pulls) and the
[color-eyre](https://github.com/eyre-rs/color-eyre/pulls) repos.
2. Pull requests on [eyre](https://github.com/eyre-rs/eyre/pulls) repo.

Not even our Circle Members are exempt from reviews! By giving feedback on this
work (and related supporting work), you can help us make sure our releases are
Expand Down
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
members = [
"color-eyre",
"color-spantrace",
"eyre"
"eyre",
"simple-eyre",
]

[workspace.package]
Expand All @@ -23,4 +24,3 @@ autocfg = "1.0"
[profile.dev.package.backtrace]
opt-level = 3


2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ implements `context` for options which you can import to make existing
[`stable-eyre`]: https://github.com/eyre-rs/stable-eyre
[`color-eyre`]: https://github.com/eyre-rs/eyre/tree/master/color-eyre
[`jane-eyre`]: https://github.com/yaahc/jane-eyre
[`simple-eyre`]: https://github.com/eyre-rs/simple-eyre
[`simple-eyre`]: https://github.com/eyre-rs/eyre/tree/master/simple-eyre
[`color-spantrace`]: https://github.com/eyre-rs/eyre/tree/master/color-spantrace
[`color-backtrace`]: https://github.com/athre0z/color-backtrace

Expand Down
5 changes: 1 addition & 4 deletions color-eyre/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = { workspace = true }
repository = { workspace = true }
readme = { workspace = true }
rust-version = { workspace = true }
include.workspace = true
include = { workspace = true }

[features]
default = ["track-caller", "capture-spantrace"]
Expand Down Expand Up @@ -43,9 +43,6 @@ wasm-bindgen-test = "0.3.15"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.release]
dev-version = false

[[example]]
name = "color-eyre-usage"
path = "examples/usage.rs"
2 changes: 1 addition & 1 deletion color-eyre/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ For an example of how to setup custom filters, check out [`examples/custom_filte
[`eyre::Report`]: https://docs.rs/eyre/*/eyre/struct.Report.html
[`eyre::Result`]: https://docs.rs/eyre/*/eyre/type.Result.html
[`Handler`]: https://docs.rs/color-eyre/*/color_eyre/struct.Handler.html
[`examples/usage.rs`]: https://github.com/eyre-rs/color-eyre/blob/master/examples/usage.rs
[`examples/usage.rs`]: https://github.com/eyre-rs/eyre/blob/master/color-eyre/examples/usage.rs
[`examples/custom_filter.rs`]: https://github.com/eyre-rs/eyre/blob/master/color-eyre/examples/custom_filter.rs
[`examples/custom_section.rs`]: https://github.com/eyre-rs/eyre/blob/master/color-eyre/examples/custom_section.rs
[`examples/multiple_errors.rs`]: https://github.com/eyre-rs/eyre/blob/master/color-eyre/examples/multiple_errors.rs
Expand Down
7 changes: 2 additions & 5 deletions color-spantrace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name = "color-spantrace"
version = "0.3.0"
description = "A pretty printer for tracing_error::SpanTrace based on color-backtrace"
documentation = "https://docs.rs/color-spantrace"
include.workspace = true

authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
readme = { workspace = true }
rust-version = { workspace = true }
include = { workspace = true }

[dependencies]
tracing-error = "0.2.0"
Expand All @@ -25,7 +25,4 @@ ansi-parser = "0.9" # used for testing color schemes

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.workspaces]
independent = true
rustdoc-args = ["--cfg", "docsrs"]
5 changes: 1 addition & 4 deletions eyre/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = { workspace = true }
repository = { workspace = true }
readme = { workspace = true }
rust-version = { workspace = true }
include.workspace = true
include = { workspace = true }

[features]
default = ["anyhow", "auto-install", "track-caller"]
Expand Down Expand Up @@ -42,6 +42,3 @@ targets = ["x86_64-unknown-linux-gnu"]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.workspaces]
independent = true

6 changes: 3 additions & 3 deletions eyre/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@
//! [`anyhow`]: https://github.com/dtolnay/anyhow
//! [`tracing_error::SpanTrace`]: https://docs.rs/tracing-error/*/tracing_error/struct.SpanTrace.html
//! [`stable-eyre`]: https://github.com/eyre-rs/stable-eyre
//! [`color-eyre`]: https://github.com/eyre-rs/color-eyre
//! [`color-eyre`]: https://github.com/eyre-rs/eyre/tree/master/color-eyre
//! [`jane-eyre`]: https://github.com/yaahc/jane-eyre
//! [`simple-eyre`]: https://github.com/eyre-rs/simple-eyre
//! [`color-spantrace`]: https://github.com/eyre-rs/color-spantrace
//! [`simple-eyre`]: https://github.com/eyre-rs/eyre/tree/master/simple-eyre
//! [`color-spantrace`]: https://github.com/eyre-rs/eyre/tree/master/color-spantrace
//! [`color-backtrace`]: https://github.com/athre0z/color-backtrace
#![cfg_attr(
nightly,
Expand Down
18 changes: 18 additions & 0 deletions simple-eyre/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- next-header -->

## [Unreleased] - ReleaseDate

## [0.3.1] - 2021-06-24
# Fixed
- Fixed lifetime inference error caused by recent `std` change.


<!-- next-url -->
[Unreleased]: https://github.com/eyre-rs/simple-eyre/compare/v0.3.1...HEAD
[0.3.1]: https://github.com/eyre-rs/simple-eyre/releases/tag/v0.3.1
21 changes: 21 additions & 0 deletions simple-eyre/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "simple-eyre"
version = "0.3.1"
description = "One of the simplest error reporters one can build ontop of eyre, defining only an error report"
documentation = "https://docs.rs/simple-eyre"

authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
readme = { workspace = true }
rust-version = { workspace = true }
include = { workspace = true }

[dependencies]
eyre = { version = "1", path = "../eyre" }
indenter = { workspace = true }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
1 change: 1 addition & 0 deletions simple-eyre/LICENSE-APACHE
1 change: 1 addition & 0 deletions simple-eyre/LICENSE-MIT
51 changes: 51 additions & 0 deletions simple-eyre/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## simple-eyre

[![Latest Version](https://img.shields.io/crates/v/simple-eyre.svg)](https://crates.io/crates/simple-eyre)
[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/simple-eyre)

This library provides a custom [`eyre::EyreHandler`] type for usage with [`eyre`] that provides
a minimal error report with no additional context. Essentially the minimal implementation of an
error reporter.

## Setup

Add the following to your toml file:

```toml
[dependencies]
simple-eyre = "0.3"
```

Then install the hook handler before constructing any `eyre::Report` types.

# Example

```rust,should_panic
use simple_eyre::eyre::{eyre, WrapErr, Report};

fn main() -> Result<(), Report> {
simple_eyre::install()?;

let e: Report = eyre!("oh no this program is just bad!");

Err(e).wrap_err("usage example successfully experienced a failure")
}
```

[`eyre::EyreHandler`]: https://docs.rs/eyre/*/eyre/trait.EyreHandler.html
[`eyre`]: https://docs.rs/eyre

#### License

<sup>
Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
</sup>

<br>

<sub>
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
be dual licensed as above, without any additional terms or conditions.
</sub>
128 changes: 128 additions & 0 deletions simple-eyre/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
//! This library provides a custom [`eyre::EyreHandler`] type for usage with [`eyre`] that provides
//! a minimal error report with no additional context. Essentially the minimal implementation of an
//! error reporter.
//!
//! ## Setup
//!
//! Add the following to your toml file:
//!
//! ```toml
//! [dependencies]
//! simple-eyre = "0.3"
//! ```
//!
//! Then install the hook handler before constructing any `eyre::Report` types.
//!
//! # Example
//!
//! ```rust,should_panic
//! use simple_eyre::eyre::{eyre, WrapErr, Report};
//!
//! fn main() -> Result<(), Report> {
//! simple_eyre::install()?;
//!
//! let e: Report = eyre!("oh no this program is just bad!");
//!
//! Err(e).wrap_err("usage example successfully experienced a failure")
//! }
//! ```
//!
//! [`eyre::EyreHandler`]: https://docs.rs/eyre/*/eyre/trait.EyreHandler.html
//! [`eyre`]: https://docs.rs/eyre
#![cfg_attr(
nightly,

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Check (stable)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (nightly, --no-default-features)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (nightly, --no-default-features --features track-caller)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (stable, --no-default-features --features track-caller)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (stable, --features pyo3)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (nightly, --all-features)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (stable, --no-default-features)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (stable)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (beta, --all-features)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (stable, --all-features)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (beta, --no-default-features --features track-caller)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (beta, --no-default-features --features auto-install)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (nightly, --features pyo3)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Miri

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Miri

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (windows-latest)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (stable, --no-default-features --features auto-install)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (nightly, --no-default-features --features auto-install)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (nightly)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (beta, --features pyo3)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (macOS-latest)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (beta, --no-default-features)

unexpected `cfg` condition name: `nightly`

Check warning on line 33 in simple-eyre/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite (beta)

unexpected `cfg` condition name: `nightly`
feature(rustdoc_missing_doc_code_examples),
warn(rustdoc::missing_doc_code_examples)
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![warn(
missing_debug_implementations,
missing_docs,
unsafe_op_in_unsafe_fn,
rust_2018_idioms,
unreachable_pub,
bad_style,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
no_mangle_generic_items,
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
unconditional_recursion,
unused,
unused_allocation,
unused_comparisons,
unused_parens,
while_true
)]
#![allow(
clippy::needless_doctest_main,
clippy::new_ret_no_self,
clippy::wrong_self_convention
)]

pub use eyre;
#[doc(hidden)]
pub use eyre::{Report, Result};

use eyre::EyreHandler;
use indenter::indented;
use std::error::Error;

/// A custom context type for minimal error reporting via `eyre`
#[derive(Debug)]
pub struct Handler;

impl EyreHandler for Handler {
fn debug(
&self,
error: &(dyn Error + 'static),
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
use core::fmt::Write as _;

if f.alternate() {
return core::fmt::Debug::fmt(error, f);
}

write!(f, "{}", error)?;

if let Some(cause) = error.source() {
write!(f, "\n\nCaused by:")?;

let multiple = cause.source().is_some();
let errors = std::iter::successors(Some(cause), |e| (*e).source());

for (n, error) in errors.enumerate() {
writeln!(f)?;

if multiple {
write!(indented(f).ind(n), "{}", error)?;
} else {
write!(indented(f), "{}", error)?;
}
}
}

Ok(())
}
}

/// Install the `simple-eyre` hook as the global error report hook.
///
/// # Details
///
/// This function must be called to enable the customization of `eyre::Report`
/// provided by `simple-eyre`. This function should be called early, ideally
/// before any errors could be encountered.
///
/// Only the first install will succeed. Calling this function after another
/// report handler has been installed will cause an error. **Note**: This
/// function _must_ be called before any `eyre::Report`s are constructed to
/// prevent the default handler from being installed.
pub fn install() -> Result<()> {
crate::eyre::set_hook(Box::new(move |_| Box::new(Handler)))?;

Ok(())
}
Loading