diff --git a/src/server/error.rs b/src/server/error.rs index 8f962bf0..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::{Body, StatusCode}; +use hyper::StatusCode; use thiserror::Error; use crate::database; @@ -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 {