mirror of
https://github.com/versia-pub/activitypub.git
synced 2025-12-06 14:48:19 +01:00
27 lines
632 B
Rust
27 lines
632 B
Rust
use std::fmt::{Display, Formatter};
|
|
|
|
/// Necessary because of this issue: https://github.com/actix/actix-web/issues/1711
|
|
#[derive(Debug)]
|
|
pub struct Error(pub(crate) anyhow::Error);
|
|
|
|
impl Display for Error {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
std::fmt::Display::fmt(&self.0, f)
|
|
}
|
|
}
|
|
|
|
impl actix_web::ResponseError for Error {
|
|
fn error_response(&self) -> actix_web::HttpResponse {
|
|
actix_web::HttpResponse::InternalServerError().body(self.to_string())
|
|
}
|
|
}
|
|
|
|
impl<T> From<T> for Error
|
|
where
|
|
T: Into<anyhow::Error>,
|
|
{
|
|
fn from(t: T) -> Self {
|
|
Error(t.into())
|
|
}
|
|
}
|