diff --git a/core/src/client.rs b/core/src/client.rs index d21855c6..aebb3abf 100644 --- a/core/src/client.rs +++ b/core/src/client.rs @@ -649,9 +649,7 @@ impl APIClient { let response = self.query_request_helper(request, true, false).await; let response = match response { Ok(r) => r, - Err(Error::Logic(status, ..)) | Err(Error::Response { status, .. }) - if status == 404 => - { + Err(e) if e.status_code() == Some(StatusCode::NOT_FOUND) => { // old server return Ok(()); } @@ -838,7 +836,7 @@ impl APIClient { status, msg: String::from_utf8_lossy(&body).to_string(), }, - true, + false, ), } } diff --git a/core/src/error.rs b/core/src/error.rs index f1153bc5..836972fc 100644 --- a/core/src/error.rs +++ b/core/src/error.rs @@ -71,6 +71,16 @@ impl Error { pub fn with_context(self, ctx: &str) -> Self { Error::WithContext(Box::new(self), ctx.to_string()) } + + pub fn status_code(&self) -> Option { + let status_code = match self { + Error::Logic(status, ..) => Some(*status), + Error::Response { status, .. } => Some(*status), + Error::WithContext(err, _) => err.status_code(), + _ => None, + }; + status_code + } } impl std::fmt::Display for Error {