Use "message" field for human friendly API error display

This commit is contained in:
Marcin Kulik
2025-07-18 11:54:14 +02:00
parent 39ceb10b2b
commit 3e5aef418e

View File

@@ -42,7 +42,7 @@ pub struct StreamChangeset {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
struct ErrorResponse { struct ErrorResponse {
reason: String, message: String,
} }
pub fn get_auth_url(config: &Config) -> Result<Url> { pub fn get_auth_url(config: &Config) -> Result<Url> {
@@ -174,12 +174,12 @@ async fn parse_stream_response<T: DeserializeOwned>(
), ),
404 => match response.json::<ErrorResponse>().await { 404 => match response.json::<ErrorResponse>().await {
Ok(json) => bail!("{}", json.reason), Ok(json) => bail!("{}", json.message),
Err(_) => bail!("{server_hostname} doesn't support streaming"), Err(_) => bail!("{server_hostname} doesn't support streaming"),
}, },
422 => match response.json::<ErrorResponse>().await { 422 => match response.json::<ErrorResponse>().await {
Ok(json) => bail!("{}", json.reason), Ok(json) => bail!("{}", json.message),
Err(_) => bail!("{server_hostname} doesn't support streaming"), Err(_) => bail!("{server_hostname} doesn't support streaming"),
}, },