Skip to content

Commit

Permalink
http-server: Print entire error call stack on internal server error
Browse files Browse the repository at this point in the history
  • Loading branch information
tontinton committed Dec 6, 2024
1 parent 771e089 commit 1c38682
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,14 @@ impl HttpError {

impl IntoResponse for HttpError {
fn into_response(self) -> Response {
if self.status.is_server_error() {
error!("Failed internal response: {}", self.message);
}
let body = if self.status.is_server_error() {
error!("Internal server error: {}", self.message);
Json(json!({"error": "Internal server error"}))
} else {
error!("User error: {}", self.message);
Json(json!({"error": self.message}))
};

let body = Json(json!({
"error": self.message,
}));
(self.status, body).into_response()
}
}
Expand All @@ -186,7 +187,7 @@ async fn post_query_handler(
if let Err(err) = workflow.execute().await {
return Err(HttpError::new(
StatusCode::INTERNAL_SERVER_ERROR,
format!("failed to execute workflow: {}", err),
format!("failed to execute workflow: {:?}", err),
));
}

Expand Down

0 comments on commit 1c38682

Please sign in to comment.