6 releases (3 breaking)

0.22.0 Jan 13, 2021
0.21.0 Nov 12, 2020
0.20.1 Sep 15, 2020
0.19.1 Aug 28, 2020
0.19.0 Jun 18, 2020
Download history 388/week @ 2020-10-05 419/week @ 2020-10-12 340/week @ 2020-10-19 682/week @ 2020-10-26 2026/week @ 2020-11-02 2728/week @ 2020-11-09 4067/week @ 2020-11-16 2073/week @ 2020-11-23 968/week @ 2020-11-30 974/week @ 2020-12-07 759/week @ 2020-12-14 547/week @ 2020-12-21 635/week @ 2020-12-28 653/week @ 2021-01-04 865/week @ 2021-01-11 691/week @ 2021-01-18

5,670 downloads per month
Used in 6 crates (2 directly)

Apache-2.0

110KB
2K SLoC

Sentry Rust SDK: sentry-anyhow

Adds support for capturing Sentry errors from anyhow::Error.

Example

use sentry_anyhow::capture_anyhow;

fn function_that_might_fail() -> anyhow::Result<()> {
    Err(anyhow::anyhow!("some kind of error"))
}

if let Err(err) = function_that_might_fail() {
    capture_anyhow(&err);
}

Resources

License: Apache-2.0


lib.rs:

Adds support for capturing Sentry errors from anyhow::Error.

This integration adds a new event source, which allows you to create events directly from an anyhow::Error struct. As it is only an event source it only needs to be enabled using the anyhow cargo feature, it does not need to be enabled in the call to sentry::init.

This integration does not need to be installed, instead it provides an extra function to capture anyhow::Error, optionally exposing it as a method on the sentry::Hub using the [AnyhowHubExt] trait.

Like a plain [std::error::Error] being captured, anyhow::Error is captured with a chain of all error sources, if present. See sentry::capture_error for details of this.

Example

use sentry_anyhow::capture_anyhow;

fn function_that_might_fail() -> anyhow::Result<()> {
    Err(anyhow::anyhow!("some kind of error"))
}

if let Err(err) = function_that_might_fail() {
    capture_anyhow(&err);
}

Dependencies

~3.5–4.5MB
~108K SLoC