diff --git a/cli/tests/00-base.result b/cli/tests/00-base.result index 4bb34066..0e46b845 100644 --- a/cli/tests/00-base.result +++ b/cli/tests/00-base.result @@ -1,5 +1,8 @@ +1 +1 b 2 false "{""k"":""v""}" a 1 true [1,2] +100000 0 99999 99999 100000 1 2 @@ -11,12 +14,15 @@ with comment " a" 3 +1 NULL 3.00 3.00 0.0000000170141183460469231731687303715884105727000 -0.0000000170141183460469231731687303715884105727000 Asia/Shanghai +3 0 0.00 1 1.00 2 2.00 +2 [1,2,3] NULL (1,'ab') NULL {'k1':'v1','k2':'v2'} (2,NULL) 1 NULL 1 ab diff --git a/cli/tests/http/06-update.result b/cli/tests/http/06-update.result index 467c029b..fafccc21 100644 --- a/cli/tests/http/06-update.result +++ b/cli/tests/http/06-update.result @@ -1 +1,2 @@ 305104 +610208 diff --git a/core/src/client.rs b/core/src/client.rs index 4b4da3c0..533d099b 100644 --- a/core/src/client.rs +++ b/core/src/client.rs @@ -651,9 +651,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) => { info!("login return 404, skip login on the old version server"); return Ok(()); } @@ -846,7 +844,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..c231fd73 100644 --- a/core/src/error.rs +++ b/core/src/error.rs @@ -71,6 +71,15 @@ impl Error { pub fn with_context(self, ctx: &str) -> Self { Error::WithContext(Box::new(self), ctx.to_string()) } + + pub fn status_code(&self) -> Option { + match self { + Error::Logic(status, ..) => Some(*status), + Error::Response { status, .. } => Some(*status), + Error::WithContext(err, _) => err.status_code(), + _ => None, + } + } } impl std::fmt::Display for Error {