Skip to content

Commit

Permalink
better error logs on 404
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Oct 15, 2023
1 parent 7aab04d commit b0050f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/webserver/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,14 @@ async fn process_sql_request(
.sql_file_cache
.get(app_state, &sql_path)
.await
.with_context(|| format!("Unable to get SQL file {:?}", sql_path))
.map_err(anyhow_err_to_actix)?;
let response = render_sql(&mut req, sql_file).await?;
Ok(req.into_response(response))
}

fn anyhow_err_to_actix(e: anyhow::Error) -> actix_web::Error {
log::error!("Error while trying to get SQL file: {:#}", e);
log::error!("{e:#}");
match e.downcast::<ErrorWithStatus>() {
Ok(err) => actix_web::Error::from(err),
Err(e) => ErrorInternalServerError(format!(
Expand All @@ -442,6 +443,7 @@ async fn serve_file(
.file_system
.modified_since(state, path.as_ref(), since, false)
.await
.with_context(|| format!("Unable to get modification time of file {:?}", path))
.map_err(anyhow_err_to_actix)?;
if !modified {
return Ok(HttpResponse::NotModified().finish());
Expand All @@ -451,6 +453,7 @@ async fn serve_file(
.file_system
.read_file(state, path.as_ref(), false)
.await
.with_context(|| format!("Unable to read file {:?}", path))
.map_err(anyhow_err_to_actix)
.map(|b| {
HttpResponse::Ok()
Expand Down

0 comments on commit b0050f6

Please sign in to comment.