This commit is contained in:
2026-01-03 00:44:20 -05:00
parent 791518eb3d
commit f8ea1fb4f7
6 changed files with 36 additions and 4 deletions

View File

@@ -29,6 +29,10 @@ pub(super) async fn get_one(
name: web::Path<String>,
) -> Result<impl Responder, HttpServerResultError> {
Ok(web::Json(
command_service.get_command_definition(&name.to_string()),
command_service
.get_command_definition(&name.to_string())
.ok_or_else(|| HttpServerResultError::CmdNotFound {
cmd: name.to_string(),
})?,
))
}

View File

@@ -23,6 +23,8 @@ pub enum HttpServerResultError {
PanelUuidNotFound { uuid: Uuid },
#[error(transparent)]
Command(#[from] crate::command::error::Error),
#[error("Command Not Found: {cmd}")]
CmdNotFound { cmd: String },
}
impl ResponseError for HttpServerResultError {
@@ -36,6 +38,7 @@ impl ResponseError for HttpServerResultError {
HttpServerResultError::InternalError { .. } => StatusCode::INTERNAL_SERVER_ERROR,
HttpServerResultError::PanelUuidNotFound { .. } => StatusCode::NOT_FOUND,
HttpServerResultError::Command(inner) => inner.status_code(),
HttpServerResultError::CmdNotFound { .. } => StatusCode::NOT_FOUND,
}
}
fn error_response(&self) -> HttpResponse {