Catch error if media request returns 4xx or 5xx
This commit is contained in:
parent
28aea5b023
commit
56427a4535
1 changed files with 1 additions and 1 deletions
|
@ -108,7 +108,7 @@ pub async fn fetch_file(
|
|||
let client = build_client(instance)?;
|
||||
let request_builder =
|
||||
build_request(instance, client, Method::GET, url);
|
||||
let response = request_builder.send().await?;
|
||||
let response = request_builder.send().await?.error_for_status()?;
|
||||
if let Some(file_size) = response.content_length() {
|
||||
if file_size > FILE_MAX_SIZE {
|
||||
return Err(FetchError::OtherError("file is too large"));
|
||||
|
|
Loading…
Reference in a new issue