Extend attempted error message parsing to also cover ErrorResponse

objects. Fixes errors in e.g. drive3 api not getting passed to delegate
error handlers.
This commit is contained in:
Björn Weinehall
2020-05-29 10:32:00 +02:00
committed by Sebastian Thiel
parent 8e9ce08aa2
commit 6ed8df5f96

View File

@@ -783,9 +783,15 @@ else {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
let json_server_error = json::from_str::<JsonServerError>(&json_err).ok();
let server_error = json::from_str::<ServerError>(&json_err)
.or_else(|_| json::from_str::<ErrorResponse>(&json_err).map(|r| r.error))
.ok();
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
json_server_error,
server_error) {
sleep(d);
continue;
}