15 lines
453 B
Rust
15 lines
453 B
Rust
use actix_web::{error::InternalError, http::StatusCode};
|
|
|
|
pub trait IntoHttpError<T> {
|
|
fn into_http_internal_err(self) -> Result<T, actix_web::Error>;
|
|
}
|
|
|
|
impl<T> IntoHttpError<T> for Result<T, anyhow::Error> {
|
|
fn into_http_internal_err(self) -> Result<T, actix_web::Error> {
|
|
self.map_err(|e| {
|
|
log::error!("Map to err: {:?}", e);
|
|
InternalError::new(e, StatusCode::INTERNAL_SERVER_ERROR).into()
|
|
})
|
|
}
|
|
}
|