use thiserror::Error;
#[derive(Error, Debug)]
pub enum ContainerError {
#[error("service not registered: {0}")]
NotRegistered(&'static str),
#[error("type mismatch when resolving: {0}")]
TypeMismatch(&'static str),
#[error("missing route parameter: {0}")]
MissingRouteParam(&'static str),
#[error("model not found")]
ModelNotFound,
}
#[cfg(feature = "container-axum")]
impl axum::response::IntoResponse for ContainerError {
fn into_response(self) -> axum::response::Response {
use axum::http::StatusCode;
let status = match &self {
ContainerError::ModelNotFound => StatusCode::NOT_FOUND,
_ => StatusCode::INTERNAL_SERVER_ERROR,
};
axum::response::IntoResponse::into_response((status, self.to_string()))
}
}