Crates.io | sentry-anyhow |
lib.rs | sentry-anyhow |
version | 0.35.0 |
source | src |
created_at | 2020-06-18 13:47:33.224003 |
updated_at | 2024-11-29 09:29:59.722247 |
description | Sentry integration for anyhow. |
homepage | https://sentry.io/welcome/ |
repository | https://github.com/getsentry/sentry-rust |
max_upload_size | |
id | 255332 |
size | 19,505 |
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.
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);
}
The backtrace
feature will enable the corresponding feature in anyhow and allow you to
capture backtraces with your events. It is enabled by default.
License: Apache-2.0