misc: replace manual From<T> for *Error with #[from]

This is a small simplification we can use since we use `thiserror`
anyway. Note that `#[from]` implies `#[source]` [0].

[0]: https://docs.rs/thiserror/2.0.12/thiserror/index.html

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-06-12 16:44:11 +02:00
committed by Rob Bradford
parent d594107c0d
commit 9bd9c0cb71
7 changed files with 6 additions and 42 deletions

View File

@@ -44,7 +44,7 @@ pub type HttpApiHandle = (thread::JoinHandle<Result<()>>, EventFd);
pub enum HttpError {
/// API request receive error
#[error("Failed to deserialize JSON: {0}")]
SerdeJsonDeserialize(#[source] SerdeError),
SerdeJsonDeserialize(#[from] SerdeError),
/// Attempt to access unsupported HTTP method
#[error("Bad Request")]
@@ -67,12 +67,6 @@ pub enum HttpError {
ApiError(#[source] ApiError),
}
impl From<serde_json::Error> for HttpError {
fn from(e: serde_json::Error) -> Self {
HttpError::SerdeJsonDeserialize(e)
}
}
const HTTP_ROOT: &str = "/api/v1";
pub fn error_response(error: HttpError, status: StatusCode) -> Response {