cleanup
This commit is contained in:
@@ -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(),
|
||||
})?,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user