Skip to content

Commit

Permalink
fix: always return 400 error
Browse files Browse the repository at this point in the history
  • Loading branch information
ngutech21 committed Feb 18, 2024
1 parent 218da98 commit 87fa89d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions moksha-mint/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,19 @@ pub enum MokshaMintError {
#[error("Not Enough tokens: {0}")]
NotEnoughTokens(String),

#[error("BtcOnchain error: {0}")]
BtcOnchain(#[from] Status),
#[error("Lnd error: {0}")]
Lnd(#[from] Status),
}

impl IntoResponse for MokshaMintError {
fn into_response(self) -> Response {
event!(Level::ERROR, "error in mint: {:?}", self);

let status = match self {
Self::Db(_) => StatusCode::INTERNAL_SERVER_ERROR,
_ => StatusCode::BAD_REQUEST,
};

let body = Json(json!({
"code": 0,
"detail": self.to_string(),
}));

(status, body).into_response()
(StatusCode::BAD_REQUEST, body).into_response()
}
}

0 comments on commit 87fa89d

Please sign in to comment.