use axum::{response::{Response, IntoResponse}, body::{boxed, self}}; use hyper::StatusCode; use thiserror::Error; #[derive(Debug, Error)] pub enum ServiceError { #[error("Solarlib error: {0}")] Solarlib(#[from] solarlib::errors::Error), #[error("Axum error: {0}")] Axum(#[from] axum::Error), } pub type StringResult = Result; pub type JsonResult = 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() } }