mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-15 19:28:00 +01:00
Favor server message when displaying upload error for 413 status
This commit is contained in:
14
src/api.rs
14
src/api.rs
@@ -62,10 +62,18 @@ pub async fn create_recording(path: &str, config: &Config) -> Result<RecordingRe
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if response.status().as_u16() == 413 {
|
if response.status().as_u16() == 413 {
|
||||||
bail!("The size of the recording exceeds the server's configured limit");
|
match response.json::<ErrorResponse>().await {
|
||||||
}
|
Ok(json) => {
|
||||||
|
bail!("{}", json.message);
|
||||||
|
}
|
||||||
|
|
||||||
response.error_for_status_ref()?;
|
Err(_) => {
|
||||||
|
bail!("The recording exceeds the server-configured size limit");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
response.error_for_status_ref()?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(response.json::<RecordingResponse>().await?)
|
Ok(response.json::<RecordingResponse>().await?)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user