Files
brk/crates/brk_website/src/error.rs
T
2026-03-27 10:00:37 -04:00

25 lines
534 B
Rust

use axum::{
body::Body,
http::{Response, StatusCode},
response::IntoResponse,
};
/// Website result type.
pub type Result<T> = std::result::Result<T, Error>;
/// Website error type that maps to HTTP status codes.
#[derive(Debug)]
pub struct Error(StatusCode, String);
impl Error {
pub fn not_found(msg: impl Into<String>) -> Self {
Self(StatusCode::NOT_FOUND, msg.into())
}
}
impl IntoResponse for Error {
fn into_response(self) -> Response<Body> {
(self.0, self.1).into_response()
}
}