dbx/src-web/src/error.rs

23 lines
457 B
Rust

use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
pub struct AppError(pub String);
impl IntoResponse for AppError {
fn into_response(self) -> Response {
(StatusCode::INTERNAL_SERVER_ERROR, self.0).into_response()
}
}
impl From<String> for AppError {
fn from(s: String) -> Self {
AppError(s)
}
}
impl From<&str> for AppError {
fn from(s: &str) -> Self {
AppError(s.to_string())
}
}