summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCyborus <cyborus@cyborus.xyz>2023-12-10 07:29:43 +0100
committerCyborus <cyborus@cyborus.xyz>2023-12-11 21:50:38 +0100
commit32d93ff87844df58f4c565b52124c6baffa8e482 (patch)
tree8e8e998eeaf2b2ae4ed2521a85d921da0c8662e9 /src
parent`PullRequest`'s `merge_commit_sha` and `merged_by` can be null (diff)
downloadforgejo-api-32d93ff87844df58f4c565b52124c6baffa8e482.tar.xz
forgejo-api-32d93ff87844df58f4c565b52124c6baffa8e482.zip
api error message optional
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 6d0aa89..a036a05 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -160,7 +160,7 @@ impl Forgejo {
},
status if status.is_client_error() => Err(ForgejoError::ApiError(
status,
- response.json::<ErrorMessage>().await?.message,
+ response.json::<ErrorMessage>().await?.message.unwrap_or_else(|| String::from("[no message]")),
)),
status => Err(ForgejoError::UnexpectedStatusCode(status)),
}
@@ -173,7 +173,7 @@ impl Forgejo {
status if status.is_success() => Ok(response.text().await?),
status if status.is_client_error() => Err(ForgejoError::ApiError(
status,
- response.json::<ErrorMessage>().await?.message,
+ response.json::<ErrorMessage>().await?.message.unwrap_or_else(|| String::from("[no message]")),
)),
status => Err(ForgejoError::UnexpectedStatusCode(status)),
}
@@ -194,7 +194,7 @@ impl Forgejo {
StatusCode::NOT_FOUND => Ok(None),
status if status.is_client_error() => Err(ForgejoError::ApiError(
status,
- response.json::<ErrorMessage>().await?.message,
+ response.json::<ErrorMessage>().await?.message.unwrap_or_else(|| String::from("[no message]")),
)),
status => Err(ForgejoError::UnexpectedStatusCode(status)),
}
@@ -203,7 +203,7 @@ impl Forgejo {
#[derive(serde::Deserialize)]
struct ErrorMessage {
- message: String,
+ message: Option<String>,
// intentionally ignored, no need for now
// url: Url
}