From 1bd946efbb5b4fbc007d7c663f70724ce796e5c6 Mon Sep 17 00:00:00 2001 From: Jonathan Richard Date: Wed, 17 Dec 2025 13:49:05 -0500 Subject: [PATCH 1/3] fix: parse forbidden errors --- burn-central-client/src/client.rs | 1 - burn-central-client/src/error.rs | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/burn-central-client/src/client.rs b/burn-central-client/src/client.rs index ad46a0f..0beabe1 100644 --- a/burn-central-client/src/client.rs +++ b/burn-central-client/src/client.rs @@ -32,7 +32,6 @@ impl ResponseExt for reqwest::blocking::Response { match self.status() { reqwest::StatusCode::NOT_FOUND => Err(ClientError::NotFound), reqwest::StatusCode::UNAUTHORIZED => Err(ClientError::Unauthorized), - reqwest::StatusCode::FORBIDDEN => Err(ClientError::Forbidden), reqwest::StatusCode::INTERNAL_SERVER_ERROR => Err(ClientError::InternalServerError), _ => Err(ClientError::ApiError { status: self.status(), diff --git a/burn-central-client/src/error.rs b/burn-central-client/src/error.rs index 6db581d..1cf60e2 100644 --- a/burn-central-client/src/error.rs +++ b/burn-central-client/src/error.rs @@ -9,6 +9,7 @@ use thiserror::Error; pub enum ApiErrorCode { ProjectAlreadyExists, UnsupportedSdkVersion, + LimitReached, // ... #[serde(other)] Unknown, @@ -31,7 +32,7 @@ impl Default for ApiErrorBody { impl Display for ApiErrorBody { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "Code: {}, Message: {}", self.code, self.message) + write!(f, "{}: {}", self.code, self.message) } } @@ -43,8 +44,6 @@ pub enum ClientError { NotFound, #[error("Unauthorized access")] Unauthorized, - #[error("Forbidden access")] - Forbidden, #[error("Internal server error")] InternalServerError, #[error("Api error {status}: {body}")] @@ -70,7 +69,14 @@ impl ClientError { } } + pub fn message(&self) -> Option { + match self { + ClientError::ApiError { body, .. } => Some(body.message.clone()), + _ => None, + } + } + pub fn is_login_error(&self) -> bool { - matches!(self, ClientError::Unauthorized | ClientError::Forbidden) + matches!(self, ClientError::Unauthorized) } } From 5f4695c206cd0083cc9c9d4cfd48146db286defa Mon Sep 17 00:00:00 2001 From: Jonathan Richard <47578360+jwric@users.noreply.github.com> Date: Wed, 17 Dec 2025 16:08:01 -0500 Subject: [PATCH 2/3] Update burn-central-client/src/error.rs Co-authored-by: Marc-Anthony <78452236+Marc-AnthonyG@users.noreply.github.com> --- burn-central-client/src/error.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/burn-central-client/src/error.rs b/burn-central-client/src/error.rs index 1cf60e2..2903489 100644 --- a/burn-central-client/src/error.rs +++ b/burn-central-client/src/error.rs @@ -69,13 +69,6 @@ impl ClientError { } } - pub fn message(&self) -> Option { - match self { - ClientError::ApiError { body, .. } => Some(body.message.clone()), - _ => None, - } - } - pub fn is_login_error(&self) -> bool { matches!(self, ClientError::Unauthorized) } From 5534f2e014d75a23d6fe2edcbfe65da02337d13d Mon Sep 17 00:00:00 2001 From: Jonathan Richard Date: Wed, 17 Dec 2025 16:09:07 -0500 Subject: [PATCH 3/3] bump --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4731939..eed0a1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,7 +111,7 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "burn-central-client" -version = "0.3.0" +version = "0.3.1" dependencies = [ "reqwest", "serde", @@ -2085,7 +2085,7 @@ checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" [[package]] name = "xtask" -version = "0.3.0" +version = "0.3.1" dependencies = [ "log", "tracel-xtask", diff --git a/Cargo.toml b/Cargo.toml index 023eba0..e61b927 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = ["burn-central-client", "xtask"] [workspace.package] edition = "2024" -version = "0.3.0" +version = "0.3.1" authors = ["Burn central team"] homepage = "https://burn.dev" repository = "https://github.com/tracel-ai/burn-central-client"