Skip to content

Commit 67573c9

Browse files
Add better error logging
1 parent 300ec24 commit 67573c9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ RUN dnf install -y time tar
1010

1111
COPY target/lambda/online-judge-rust/bootstrap ${LAMBDA_RUNTIME_DIR}/bootstrap
1212

13+
ENV RUST_BACKTRACE=1
14+
1315
# This is passed in as argv[1] to /var/runtime/bootstrap. The value shouldn't matter.
1416
CMD [ "_handler" ]

src/error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
//! Taken from https://github.com/tokio-rs/axum/blob/main/examples/anyhow-error-response/src/main.rs
33
44
use axum::{http::StatusCode, response::{IntoResponse, Response}};
5+
use lambda_http::tracing::error;
56

67
// Make our own error that wraps `anyhow::Error`.
78
pub struct AppError(anyhow::Error);
89

910
// Tell axum how to convert `AppError` into a response.
1011
impl IntoResponse for AppError {
1112
fn into_response(self) -> Response {
12-
println!("Returning Internal Server Error: {}", self.0);
13+
error!("Returning Internal Server Error: {:?}", self.0);
1314
(
1415
StatusCode::INTERNAL_SERVER_ERROR,
15-
format!("Internal Server Error: {}", self.0),
16+
format!("Internal Server Error: {:?}", self.0),
1617
)
1718
.into_response()
1819
}

0 commit comments

Comments
 (0)