mas_axum_utils/
error_wrapper.rs1use axum::response::{IntoResponse, Response};
8use http::StatusCode;
9
10use crate::record_error;
11
12#[derive(Debug, thiserror::Error)]
14#[error(transparent)]
15pub struct ErrorWrapper<T>(#[from] pub T);
16
17impl<T> IntoResponse for ErrorWrapper<T>
18where
19 T: std::error::Error + 'static,
20{
21 fn into_response(self) -> Response {
22 let sentry_event_id = record_error!(self.0);
24 (
25 StatusCode::INTERNAL_SERVER_ERROR,
26 sentry_event_id,
27 self.0.to_string(),
28 )
29 .into_response()
30 }
31}