From 5895dc113bfa19eabec6893bfdf6aaf472a56300 Mon Sep 17 00:00:00 2001 From: korelstar Date: Mon, 24 Oct 2016 12:21:02 +0200 Subject: [PATCH] more logging (#145) --- .../owncloud/notes/persistence/NoteServerSyncHelper.java | 8 ++++++++ .../niedermann/owncloud/notes/util/NotesClientUtil.java | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java index cb577ebe..e062a164 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteServerSyncHelper.java @@ -172,6 +172,7 @@ public class NoteServerSyncHelper { private final boolean onlyLocalChanges; private final List callbacks = new ArrayList<>(); private NotesClient client; + private List exceptions = new ArrayList<>(); public SyncTask(boolean onlyLocalChanges) { this.onlyLocalChanges = onlyLocalChanges; @@ -293,8 +294,12 @@ public class NoteServerSyncHelper { } status = LoginStatus.OK; } catch (IOException e) { + Log.e(getClass().getSimpleName(), "Exception", e); + exceptions.add(e); status = LoginStatus.CONNECTION_FAILED; } catch (JSONException e) { + Log.e(getClass().getSimpleName(), "Exception", e); + exceptions.add(e); status = LoginStatus.JSON_FAILED; } return status; @@ -305,6 +310,9 @@ public class NoteServerSyncHelper { super.onPostExecute(status); if (status!=LoginStatus.OK) { Toast.makeText(appContext, appContext.getString(R.string.error_sync, appContext.getString(status.str)), Toast.LENGTH_LONG).show(); + for (Throwable e : exceptions) { + Toast.makeText(appContext, e.getClass().getName() + ": " + e.getMessage(), Toast.LENGTH_LONG).show(); + } } syncActive = false; // notify callbacks diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/NotesClientUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/util/NotesClientUtil.java index 3bf52171..6a866a93 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/NotesClientUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/util/NotesClientUtil.java @@ -1,6 +1,7 @@ package it.niedermann.owncloud.notes.util; import android.util.Base64; +import android.util.Log; import org.json.JSONArray; import org.json.JSONException; @@ -80,10 +81,13 @@ public class NotesClientUtil { return LoginStatus.SERVER_FAILED; } } catch (MalformedURLException e) { + Log.e(NotesClientUtil.class.getSimpleName(), "Exception", e); return LoginStatus.CONNECTION_FAILED; } catch (IOException e) { + Log.e(NotesClientUtil.class.getSimpleName(), "Exception", e); return LoginStatus.CONNECTION_FAILED; } catch (JSONException e) { + Log.e(NotesClientUtil.class.getSimpleName(), "Exception", e); return LoginStatus.JSON_FAILED; } }