Skip to content

Commit e60ad00

Browse files
committed
remove special AxumNope::InternalTokio error variant
1 parent f1f1cf8 commit e60ad00

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

src/web/error.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ pub enum AxumNope {
157157
InternalServerError,
158158
#[error("internal error")]
159159
InternalError(#[from] anyhow::Error),
160-
#[error("internal threading error")]
161-
InternalTokio(#[from] tokio::task::JoinError),
162160
}
163161

164162
impl IntoResponse for AxumNope {
@@ -221,25 +219,19 @@ impl IntoResponse for AxumNope {
221219
}
222220
.into_response()
223221
}
224-
AxumNope::InternalError(source) => generate_internal_error_page(source).into_response(),
225-
AxumNope::InternalTokio(source) => generate_internal_error_page(source).into_response(),
226-
}
227-
}
228-
}
229-
230-
fn generate_internal_error_page<E: Into<anyhow::Error>>(error: E) -> impl IntoResponse {
231-
let error = anyhow::anyhow!(error);
232-
233-
let web_error = crate::web::AxumErrorPage {
234-
title: "Internal Server Error",
235-
message: Cow::Owned(error.to_string()),
236-
status: StatusCode::INTERNAL_SERVER_ERROR,
237-
};
222+
AxumNope::InternalError(source) => {
223+
let web_error = crate::web::AxumErrorPage {
224+
title: "Internal Server Error",
225+
message: Cow::Owned(source.to_string()),
226+
status: StatusCode::INTERNAL_SERVER_ERROR,
227+
};
238228

239-
// TODO: check: does the sentry tower layer add the request as context?
240-
crate::utils::report_error(&error);
229+
crate::utils::report_error(&source);
241230

242-
web_error
231+
web_error.into_response()
232+
}
233+
}
234+
}
243235
}
244236

245237
#[cfg(test)]

src/web/sitemap.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{
55
utils::{get_config, ConfigName},
66
web::{error::AxumNope, page::WebPage},
77
};
8+
use anyhow::Context;
89
use axum::{
910
extract::{Extension, Path},
1011
response::IntoResponse,
@@ -91,7 +92,8 @@ pub(crate) async fn sitemap_handler(
9192
})
9293
.collect())
9394
})
94-
.await??;
95+
.await
96+
.context("failed to join thread")??;
9597

9698
Ok(SitemapXml { releases })
9799
}
@@ -115,7 +117,8 @@ pub(crate) async fn about_builds_handler(
115117
let mut conn = pool.get()?;
116118
get_config::<String>(&mut conn, ConfigName::RustcVersion)
117119
})
118-
.await??;
120+
.await
121+
.context("failed to join thread")??;
119122

120123
Ok(AboutBuilds {
121124
rustc_version,

0 commit comments

Comments
 (0)