Handle exceptions due Downsync more gracefully

This commit is contained in:
stefan-niedermann 2020-01-02 09:36:00 +01:00
parent 2dbaf41d9f
commit 909fd384fa
3 changed files with 12 additions and 3 deletions

View file

@ -8,7 +8,8 @@ public enum LoginStatus {
OK(0),
NO_NETWORK(R.string.error_no_network),
JSON_FAILED(R.string.error_json),
PROBLEM_WITH_FILES_APP(R.string.error_files_app);
PROBLEM_WITH_FILES_APP(R.string.error_files_app),
UNKNOWN_PROBLEM(R.string.error_unknown);
@StringRes
public final int str;

View file

@ -383,20 +383,27 @@ public class NoteServerSyncHelper {
dbHelper.updateETag(localAccount.getId(), localAccount.getEtag());
dbHelper.updateModified(localAccount.getId(), localAccount.getModified());
return LoginStatus.OK;
} catch (JSONException e) {
} catch (JSONException | NullPointerException e) {
Log.e(TAG, "Exception", e);
exceptions.add(e);
status = LoginStatus.JSON_FAILED;
} catch (NextcloudHttpRequestFailedException e) {
Log.d(TAG, "Server returned HTTP Status Code " + e.getStatusCode() + " - " + e.getMessage());
if (e.getStatusCode() == 304) {
Log.d(TAG, "Server returned HTTP Status Code 304 - Not Modified");
return LoginStatus.OK;
} else {
e.printStackTrace();
exceptions.add(e);
return LoginStatus.JSON_FAILED;
}
} catch (NextcloudApiNotRespondingException e) {
e.printStackTrace();
exceptions.add(e);
return LoginStatus.PROBLEM_WITH_FILES_APP;
} catch (Exception e) {
e.printStackTrace();
exceptions.add(e);
return LoginStatus.UNKNOWN_PROBLEM;
}
return status;
}

View file

@ -53,6 +53,7 @@
<string name="error_json">is the Notes app activated on the server?</string>
<string name="error_no_network">no network connection</string>
<string name="error_files_app">do you have installed the files app?</string>
<string name="error_unknown">an unknown error happened.</string>
<!-- Snackbar Actions -->