From 88f8233ca1f10484efd27cd388daee94a552c31f Mon Sep 17 00:00:00 2001 From: Jack Kleeman Date: Thu, 16 May 2024 18:32:32 +0100 Subject: [PATCH] Support cloud errors that are not json --- cli/src/clients/cloud/client.rs | 2 +- cli/src/clients/errors.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cli/src/clients/cloud/client.rs b/cli/src/clients/cloud/client.rs index debff9c900..11c977d527 100644 --- a/cli/src/clients/cloud/client.rs +++ b/cli/src/clients/cloud/client.rs @@ -59,7 +59,7 @@ where return Err(Error::Api(Box::new(ApiError { http_status_code, url, - body: serde_json::from_str(&body)?, + body: serde_json::from_str(&body).unwrap_or(body.into()), }))); } diff --git a/cli/src/clients/errors.rs b/cli/src/clients/errors.rs index b3bba9840e..1bf63cbce1 100644 --- a/cli/src/clients/errors.rs +++ b/cli/src/clients/errors.rs @@ -20,6 +20,15 @@ pub struct ApiErrorBody { message: String, } +impl From for ApiErrorBody { + fn from(message: String) -> Self { + Self { + message, + restate_code: None, + } + } +} + #[derive(Debug, Clone)] pub struct ApiError { pub http_status_code: reqwest::StatusCode,