Skip to content

Commit 6accd3a

Browse files
committed
chore: add internal errors
1 parent 19a8d68 commit 6accd3a

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

api/src/interactions/mod.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use ed25519_dalek::{PUBLIC_KEY_LENGTH, Verifier, VerifyingKey};
88
use hex::FromHex;
99
use http::{HeaderMap, StatusCode};
1010
use http_body_util::BodyExt;
11+
use lambda_http::tracing::error;
1112
use once_cell::sync::Lazy;
1213
use serde_json::{Value, json};
1314
use twilight_model::application::command::CommandType;
@@ -46,7 +47,10 @@ pub async fn pubkey_middleware(request: Request, next: Next) -> Result<Response,
4647
.get("x-signature-ed25519")
4748
.and_then(|v| v.to_str().ok())
4849
{
49-
hex_sig.parse().map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?
50+
hex_sig.parse().map_err(|e| {
51+
error!("Internal Server Error: {:?}", e);
52+
StatusCode::INTERNAL_SERVER_ERROR
53+
})?
5054
} else {
5155
return Err(StatusCode::BAD_REQUEST);
5256
};
@@ -55,7 +59,10 @@ pub async fn pubkey_middleware(request: Request, next: Next) -> Result<Response,
5559
let body = body
5660
.collect()
5761
.await
58-
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?
62+
.map_err(|e| {
63+
error!("Internal Server Error: {:?}", e);
64+
StatusCode::INTERNAL_SERVER_ERROR
65+
})?
5966
.to_bytes();
6067

6168
if PUB_KEY
@@ -158,7 +165,13 @@ async fn register_commands(
158165
}
159166

160167

161-
let application_id = app_state.discord_bot.current_user_application().await.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?.model().await.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?.id;
168+
let application_id = app_state.discord_bot.current_user_application().await.map_err(|e| {
169+
error!("Internal Server Error: {:?}", e);
170+
StatusCode::INTERNAL_SERVER_ERROR
171+
})?.model().await.map_err(|e| {
172+
error!("Internal Server Error: {:?}", e);
173+
StatusCode::INTERNAL_SERVER_ERROR
174+
})?.id;
162175
let resp = app_state.discord_bot.interaction(application_id)
163176
.set_global_commands(
164177
&[
@@ -198,6 +211,13 @@ async fn register_commands(
198211
#[allow(deprecated)]
199212
dm_permission: None,
200213
}],
201-
).await.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?.model().await.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
214+
).await.map_err(|e| {
215+
error!("Internal Server Error: {:?}", e);
216+
StatusCode::INTERNAL_SERVER_ERROR
217+
})?.model().await.map_err(|e| {
218+
error!("Internal Server Error: {:?}", e);
219+
StatusCode::INTERNAL_SERVER_ERROR
220+
})?;
202221
Ok(Json(json!(resp)))
203-
}
222+
}
223+

0 commit comments

Comments
 (0)