diff --git a/libs/utils/src/http/endpoint.rs b/libs/utils/src/http/endpoint.rs
index a60971abf0..31dbdd7bc1 100644
--- a/libs/utils/src/http/endpoint.rs
+++ b/libs/utils/src/http/endpoint.rs
@@ -84,6 +84,9 @@ where
info!("Handling request");
}
+ // Take a copy of the path for error logging
+ let path = request.uri().path().to_string();
+
// No special handling for panics here. There's a `tracing_panic_hook` from another
// module to do that globally.
let res = handler(request).await;
@@ -110,7 +113,7 @@ where
}
Ok(response)
}
- Err(err) => Ok(api_error_handler(err)),
+ Err(err) => Ok(api_error_handler(err, Some(&path))),
}
}
.instrument(request_span)
diff --git a/libs/utils/src/http/error.rs b/libs/utils/src/http/error.rs
index d55823b0b7..66af3d5901 100644
--- a/libs/utils/src/http/error.rs
+++ b/libs/utils/src/http/error.rs
@@ -108,7 +108,7 @@ impl HttpErrorBody {
pub async fn route_error_handler(err: routerify::RouteError) -> Response
{
match err.downcast::() {
- Ok(api_error) => api_error_handler(*api_error),
+ Ok(api_error) => api_error_handler(*api_error, None),
Err(other_error) => {
// We expect all the request handlers to return an ApiError, so this should
// not be reached. But just in case.
@@ -121,12 +121,16 @@ pub async fn route_error_handler(err: routerify::RouteError) -> Response {
}
}
-pub fn api_error_handler(api_error: ApiError) -> Response {
+pub fn api_error_handler(api_error: ApiError, path: Option<&str>) -> Response {
// Print a stack trace for Internal Server errors
match api_error {
ApiError::Forbidden(_) | ApiError::Unauthorized(_) => {
- warn!("Error processing HTTP request: {api_error:#}")
+ warn!(
+ "Error processing HTTP request: {api_error:#} {}{}",
+ path.as_ref().map(|_| "at").unwrap_or(""),
+ path.unwrap_or("")
+ )
}
ApiError::ResourceUnavailable(_) => info!("Error processing HTTP request: {api_error:#}"),
ApiError::NotFound(_) => info!("Error processing HTTP request: {api_error:#}"),