From bcdea7168571067a82e1f50080e50652bf836e6a Mon Sep 17 00:00:00 2001 From: Wojciech Sromek Date: Thu, 9 May 2024 10:24:02 +0200 Subject: [PATCH 1/3] cleanup: Remove legacy error implementation --- src/server/error.rs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/server/error.rs b/src/server/error.rs index 8f962bf0..e8365bfb 100644 --- a/src/server/error.rs +++ b/src/server/error.rs @@ -71,30 +71,6 @@ pub enum Error { Other(#[from] EyreError), } -impl Error { - #[allow(clippy::enum_glob_use)] - #[must_use] - pub fn to_response(&self) -> hyper::Response { - use Error::*; - - let status_code = match self { - InvalidMethod => StatusCode::METHOD_NOT_ALLOWED, - InvalidPath | IdentityCommitmentNotFound => StatusCode::NOT_FOUND, - InvalidContentType => StatusCode::UNSUPPORTED_MEDIA_TYPE, - IndexOutOfBounds - | RootTooOld - | InvalidCommitment - | DuplicateCommitment - | InvalidSerialization(_) => StatusCode::BAD_REQUEST, - _ => StatusCode::INTERNAL_SERVER_ERROR, - }; - hyper::Response::builder() - .status(status_code) - .body(hyper::Body::from(self.to_string())) - .expect("Failed to convert error string into hyper::Body") - } -} - impl Error { fn to_status_code(&self) -> StatusCode { match self { From 1cf7b2ab15e5b744c1305312d867eb30cb8acb2a Mon Sep 17 00:00:00 2001 From: Wojciech Sromek Date: Thu, 9 May 2024 10:47:50 +0200 Subject: [PATCH 2/3] removed unused Body import --- src/server/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/error.rs b/src/server/error.rs index e8365bfb..0372fd1f 100644 --- a/src/server/error.rs +++ b/src/server/error.rs @@ -1,6 +1,6 @@ use anyhow::Error as EyreError; use axum::response::IntoResponse; -use hyper::{Body, StatusCode}; +use hyper::{StatusCode}; use thiserror::Error; use crate::database; From 1797a89b4cdd305bdf02c4f47666976cb4bc8830 Mon Sep 17 00:00:00 2001 From: Wojciech Sromek Date: Thu, 9 May 2024 11:15:45 +0200 Subject: [PATCH 3/3] fix lint --- src/server/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/error.rs b/src/server/error.rs index 0372fd1f..0ba8ec87 100644 --- a/src/server/error.rs +++ b/src/server/error.rs @@ -1,6 +1,6 @@ use anyhow::Error as EyreError; use axum::response::IntoResponse; -use hyper::{StatusCode}; +use hyper::StatusCode; use thiserror::Error; use crate::database;