diff options
author | Cyborus <cyborus@cyborus.xyz> | 2023-12-10 07:29:43 +0100 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2023-12-11 21:50:38 +0100 |
commit | 32d93ff87844df58f4c565b52124c6baffa8e482 (patch) | |
tree | 8e8e998eeaf2b2ae4ed2521a85d921da0c8662e9 /src | |
parent | `PullRequest`'s `merge_commit_sha` and `merged_by` can be null (diff) | |
download | forgejo-api-32d93ff87844df58f4c565b52124c6baffa8e482.tar.xz forgejo-api-32d93ff87844df58f4c565b52124c6baffa8e482.zip |
api error message optional
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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 } |