mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-19 00:10:26 +00:00
More apt error messages for Reddit outages
This commit is contained in:
parent
b3b5782373
commit
41b3dc5739
3 changed files with 23 additions and 15 deletions
|
@ -122,6 +122,8 @@ pub async fn json(path: String, quarantine: bool) -> Result<Value, String> {
|
|||
// Fetch the url...
|
||||
match request(url.clone(), quarantine).await {
|
||||
Ok(response) => {
|
||||
let status = response.status();
|
||||
|
||||
// asynchronously aggregate the chunks of the body
|
||||
match hyper::body::aggregate(response).await {
|
||||
Ok(body) => {
|
||||
|
@ -146,7 +148,13 @@ pub async fn json(path: String, quarantine: bool) -> Result<Value, String> {
|
|||
Ok(json)
|
||||
}
|
||||
}
|
||||
Err(e) => err("Failed to parse page JSON data", e.to_string()),
|
||||
Err(e) => {
|
||||
if status.is_server_error() {
|
||||
Err("Reddit is having issues, check if there's an outage".to_string())
|
||||
} else {
|
||||
err("Failed to parse page JSON data", e.to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => err("Failed receiving body from Reddit", e.to_string()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue