chore: add temp sentry logging system

This commit is contained in:
Zomatree
2025-10-22 21:28:01 +01:00
parent 20a4816235
commit db19957de5
4 changed files with 9 additions and 3 deletions

1
Cargo.lock generated
View File

@@ -6905,6 +6905,7 @@ dependencies = [
"revolt_rocket_okapi",
"rocket",
"schemars 0.8.22",
"sentry",
"serde",
"serde_json",
"utoipa",

View File

@@ -16,7 +16,7 @@ mod voice_client;
pub use voice_client::VoiceClient;
async fn get_connection() -> Result<Conn> {
_get_connection().await.to_internal_error()
_get_connection().await.map_err(|_| create_error!(InternalError))
}
pub async fn raise_if_in_voice(user: &User, channel_id: &str) -> Result<()> {

View File

@@ -15,8 +15,9 @@ 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"]
default = ["serde", "sentry"]
[dependencies]
# Serialisation
@@ -36,3 +37,5 @@ revolt_okapi = { version = "0.9.1", optional = true }
log = "0.4"
# Axum
axum = { version = "0.7.5", optional = true }
sentry = { version = "0.31.5", optional = true }

View File

@@ -226,7 +226,7 @@ pub trait ToRevoltError<T> {
fn to_internal_error(self) -> Result<T, Error>;
}
impl<T, E: std::fmt::Debug> ToRevoltError<T> for Result<T, E> {
impl<T, E: std::fmt::Debug + std::error::Error> ToRevoltError<T> for Result<T, E> {
#[track_caller]
fn to_internal_error(self) -> Result<T, Error> {
let loc = Location::caller();
@@ -234,6 +234,8 @@ impl<T, E: std::fmt::Debug> ToRevoltError<T> for Result<T, E> {
self
.map_err(|e| {
log::error!("{e:?}");
#[cfg(feature = "sentry")]
sentry::capture_error(&e);
Error {
error_type: ErrorType::InternalError,