fix: make sentry dep optional

This commit is contained in:
Zomatree
2025-07-31 10:46:47 +01:00
parent 249a4818fc
commit d7cf809424
5 changed files with 16 additions and 6 deletions

View File

@@ -15,6 +15,7 @@ utoipa = ["dep:utoipa"]
rocket = ["dep:rocket", "dep:serde_json"]
axum = ["dep:axum", "dep:serde_json"]
okapi = ["dep:revolt_rocket_okapi", "dep:revolt_okapi", "schemas"]
sentry = ["dep:sentry"]
default = ["serde"]
@@ -36,4 +37,4 @@ revolt_okapi = { version = "0.9.1", optional = true }
axum = { version = "0.7.5", optional = true }
# Sentry
sentry = "0.31.5"
sentry = { version = "0.31.5", optional = true }

View File

@@ -213,7 +213,12 @@ pub trait ToRevoltError<T>: Sized {
impl<T, E: std::error::Error> ToRevoltError<T> for Result<T, E> {
fn capture_error(self) -> Self {
self.inspect_err(|e| { sentry::capture_error(e); })
#[allow(unused_variables)]
self.inspect_err(|e| {
#[cfg(feature = "sentry")]
sentry::capture_error(e);
})
}
#[track_caller]
@@ -233,7 +238,11 @@ impl<T, E: std::error::Error> ToRevoltError<T> for Result<T, E> {
impl<T: std::error::Error> ToRevoltError<T> for Option<T> {
fn capture_error(self) -> Self {
self.inspect(|e| { sentry::capture_error(e); })
#[allow(unused_variables)]
self.inspect(|e| {
#[cfg(feature = "sentry")]
sentry::capture_error(e);
})
}
#[track_caller]