From 0bc8ee974a0d4a5ca4de3a1d881706f44a140145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=AE=80=E8=88=9F?= Date: Wed, 10 Jul 2024 18:21:24 +0800 Subject: [PATCH] fix error. (#279) --- explorer/src/service/error.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/explorer/src/service/error.rs b/explorer/src/service/error.rs index 47af59f..46716e4 100644 --- a/explorer/src/service/error.rs +++ b/explorer/src/service/error.rs @@ -15,11 +15,13 @@ pub enum ExplorerError { ReqwestErr(reqwest::Error), ParseFloatErr(ParseFloatError), } + impl From for ExplorerError { fn from(e: ParseFloatError) -> Self { ExplorerError::ParseFloatErr(e) } } + impl From for ExplorerError { fn from(e: reqwest::Error) -> Self { ExplorerError::ReqwestErr(e) @@ -74,12 +76,12 @@ impl IntoResponse for ExplorerError { fn into_response(self) -> Response { let err_msg = match self { ExplorerError::Custom(e) => e, - ExplorerError::DBErr(e) => { - if let RowNotFound = e { + ExplorerError::DBErr(e) => match e { + RowNotFound => { return (StatusCode::NOT_FOUND, "not found").into_response(); } - e.to_string() - } + _ => e.to_string(), + }, ExplorerError::IOErr(e) => e.to_string(), ExplorerError::TomlDeErr(e) => e.to_string(), ExplorerError::HexErr(e) => e.to_string(),