api error message optional
This commit is contained in:
parent
3c1675976c
commit
32d93ff878
|
@ -160,7 +160,7 @@ impl Forgejo {
|
||||||
},
|
},
|
||||||
status if status.is_client_error() => Err(ForgejoError::ApiError(
|
status if status.is_client_error() => Err(ForgejoError::ApiError(
|
||||||
status,
|
status,
|
||||||
response.json::<ErrorMessage>().await?.message,
|
response.json::<ErrorMessage>().await?.message.unwrap_or_else(|| String::from("[no message]")),
|
||||||
)),
|
)),
|
||||||
status => Err(ForgejoError::UnexpectedStatusCode(status)),
|
status => Err(ForgejoError::UnexpectedStatusCode(status)),
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ impl Forgejo {
|
||||||
status if status.is_success() => Ok(response.text().await?),
|
status if status.is_success() => Ok(response.text().await?),
|
||||||
status if status.is_client_error() => Err(ForgejoError::ApiError(
|
status if status.is_client_error() => Err(ForgejoError::ApiError(
|
||||||
status,
|
status,
|
||||||
response.json::<ErrorMessage>().await?.message,
|
response.json::<ErrorMessage>().await?.message.unwrap_or_else(|| String::from("[no message]")),
|
||||||
)),
|
)),
|
||||||
status => Err(ForgejoError::UnexpectedStatusCode(status)),
|
status => Err(ForgejoError::UnexpectedStatusCode(status)),
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ impl Forgejo {
|
||||||
StatusCode::NOT_FOUND => Ok(None),
|
StatusCode::NOT_FOUND => Ok(None),
|
||||||
status if status.is_client_error() => Err(ForgejoError::ApiError(
|
status if status.is_client_error() => Err(ForgejoError::ApiError(
|
||||||
status,
|
status,
|
||||||
response.json::<ErrorMessage>().await?.message,
|
response.json::<ErrorMessage>().await?.message.unwrap_or_else(|| String::from("[no message]")),
|
||||||
)),
|
)),
|
||||||
status => Err(ForgejoError::UnexpectedStatusCode(status)),
|
status => Err(ForgejoError::UnexpectedStatusCode(status)),
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ impl Forgejo {
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
struct ErrorMessage {
|
struct ErrorMessage {
|
||||||
message: String,
|
message: Option<String>,
|
||||||
// intentionally ignored, no need for now
|
// intentionally ignored, no need for now
|
||||||
// url: Url
|
// url: Url
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue