Catch error if media request returns 4xx or 5xx

This commit is contained in:
silverpill 2022-12-03 11:16:40 +00:00
parent 28aea5b023
commit 56427a4535

View file

@ -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"));