use thiserror::Error; use axum::response::{Response, IntoResponse}; use axum::http::StatusCode; use axum::body; use axum::Json; #[derive(Debug, Error)] pub enum ServiceError { #[error("Waifulib error: {0}")] Solarlib(#[from] solarlib::errors::Error), #[error("Axum error: {0}")] Axum(#[from] axum::Error), } pub type StringResult = std::result::Result; pub type JsonResult = std::result::Result; impl IntoResponse for ServiceError { fn into_response(self) -> Response { let body = body::boxed(body::Full::from(self.to_string())); Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(body) .unwrap() } }