34 releases

0.34.0 Jun 5, 2024
0.32.3 Apr 16, 2024
0.32.2 Jan 30, 2024
0.32.1 Dec 18, 2023
0.19.0 Jun 18, 2020

#21 in #sentry

Download history 35285/week @ 2024-07-23 35026/week @ 2024-07-30 36380/week @ 2024-08-06 43186/week @ 2024-08-13 60005/week @ 2024-08-20 64690/week @ 2024-08-27 55989/week @ 2024-09-03 50381/week @ 2024-09-10 50961/week @ 2024-09-17 63197/week @ 2024-09-24 84598/week @ 2024-10-01 40850/week @ 2024-10-08 88685/week @ 2024-10-15 63424/week @ 2024-10-22 75152/week @ 2024-10-29 34695/week @ 2024-11-05

267,757 downloads per month
Used in 12 crates (2 directly)

Apache-2.0

250KB
4.5K SLoC

Sentry

Sentry Rust SDK: sentry-anyhow

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);
}

Features

The backtrace feature will enable the corresponding feature in anyhow and allow you to capture backtraces with your events. It is enabled by default.

Resources

License: Apache-2.0

Dependencies

~9–17MB
~225K SLoC