add some extra help to the json decode error

This commit is contained in:
Damien Elmes 2020-08-06 15:02:56 +10:00
parent a109bdaf60
commit 41d37464e6

View file

@ -255,13 +255,23 @@ fn error_for_status_code(info: String, code: StatusCode) -> AnkiError {
} }
} }
fn guess_reqwest_error(info: String) -> AnkiError { fn guess_reqwest_error(mut info: String) -> AnkiError {
if info.contains("dns error: cancelled") { if info.contains("dns error: cancelled") {
return AnkiError::Interrupted; return AnkiError::Interrupted;
} }
let kind = if info.contains("unreachable") || info.contains("dns") { let kind = if info.contains("unreachable") || info.contains("dns") {
NetworkErrorKind::Offline NetworkErrorKind::Offline
} else { } else {
if info.contains("invalid type") {
info = format!(
"{} {} {}\n\n{}",
"Please force a full sync in the Preferences screen to bring your devices into sync.",
"Then, please use the Check Database feature, and sync to your other devices.",
"If problems persist, please post on the support forum.",
info,
);
}
NetworkErrorKind::Other NetworkErrorKind::Other
}; };
AnkiError::NetworkError { info, kind } AnkiError::NetworkError { info, kind }