forked from neri/datatrash
add a custom response for full storage
This commit is contained in:
parent
becfefb070
commit
eddbeec7ef
|
@ -173,10 +173,20 @@ async fn write_to_file(
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file.write_all(&chunk).await.map_err(|write_err| {
|
file.write_all(&chunk)
|
||||||
log::error!("could not write file {:?}", write_err);
|
.await
|
||||||
error::ErrorInternalServerError("could not write file")
|
.map_err(|write_err| match write_err.kind() {
|
||||||
})?;
|
std::io::ErrorKind::StorageFull => {
|
||||||
|
log::warn!("storage is full {:?}", write_err);
|
||||||
|
error::ErrorServiceUnavailable(
|
||||||
|
"storage is full, you will need to wait for some files to expire",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
log::error!("could not write file {:?}", write_err);
|
||||||
|
error::ErrorInternalServerError("could not write file")
|
||||||
|
}
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
Ok(written_bytes)
|
Ok(written_bytes)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue