Skip to content

Commit

Permalink
Merge pull request #726 from worldcoin/B-1581/write-script-to-migrate…
Browse files Browse the repository at this point in the history
…-unverify-requests-from-deletion-portal-to-pop

cleanup: Remove legacy error implementation
  • Loading branch information
wojciechsromek authored May 9, 2024
2 parents 85466a9 + 1797a89 commit c83d444
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions src/server/error.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Body> {
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 {
Expand Down

0 comments on commit c83d444

Please sign in to comment.