21 lines
481 B
Rust
21 lines
481 B
Rust
use axum::{Json, response::IntoResponse};
|
|
use reqwest::StatusCode;
|
|
use serde::Serialize;
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct Error {
|
|
pub status: u16,
|
|
pub message: String,
|
|
}
|
|
|
|
impl IntoResponse for Error {
|
|
fn into_response(self) -> axum::response::Response {
|
|
(
|
|
StatusCode::from_u16(self.status)
|
|
.expect("The status code provided was not a valid status code"),
|
|
Json(self),
|
|
)
|
|
.into_response()
|
|
}
|
|
}
|