mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
Rob Bradford
parent
d594107c0d
commit
9bd9c0cb71
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user