more logging (#145)

This commit is contained in:
korelstar 2016-10-24 12:21:02 +02:00 committed by Niedermann IT-Dienstleistungen
parent abf8dc4702
commit 5895dc113b
2 changed files with 12 additions and 0 deletions

View file

@ -172,6 +172,7 @@ public class NoteServerSyncHelper {
private final boolean onlyLocalChanges; private final boolean onlyLocalChanges;
private final List<ICallback> callbacks = new ArrayList<>(); private final List<ICallback> callbacks = new ArrayList<>();
private NotesClient client; private NotesClient client;
private List<Throwable> exceptions = new ArrayList<>();
public SyncTask(boolean onlyLocalChanges) { public SyncTask(boolean onlyLocalChanges) {
this.onlyLocalChanges = onlyLocalChanges; this.onlyLocalChanges = onlyLocalChanges;
@ -293,8 +294,12 @@ public class NoteServerSyncHelper {
} }
status = LoginStatus.OK; status = LoginStatus.OK;
} catch (IOException e) { } catch (IOException e) {
Log.e(getClass().getSimpleName(), "Exception", e);
exceptions.add(e);
status = LoginStatus.CONNECTION_FAILED; status = LoginStatus.CONNECTION_FAILED;
} catch (JSONException e) { } catch (JSONException e) {
Log.e(getClass().getSimpleName(), "Exception", e);
exceptions.add(e);
status = LoginStatus.JSON_FAILED; status = LoginStatus.JSON_FAILED;
} }
return status; return status;
@ -305,6 +310,9 @@ public class NoteServerSyncHelper {
super.onPostExecute(status); super.onPostExecute(status);
if (status!=LoginStatus.OK) { if (status!=LoginStatus.OK) {
Toast.makeText(appContext, appContext.getString(R.string.error_sync, appContext.getString(status.str)), Toast.LENGTH_LONG).show(); 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; syncActive = false;
// notify callbacks // notify callbacks

View file

@ -1,6 +1,7 @@
package it.niedermann.owncloud.notes.util; package it.niedermann.owncloud.notes.util;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -80,10 +81,13 @@ public class NotesClientUtil {
return LoginStatus.SERVER_FAILED; return LoginStatus.SERVER_FAILED;
} }
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
Log.e(NotesClientUtil.class.getSimpleName(), "Exception", e);
return LoginStatus.CONNECTION_FAILED; return LoginStatus.CONNECTION_FAILED;
} catch (IOException e) { } catch (IOException e) {
Log.e(NotesClientUtil.class.getSimpleName(), "Exception", e);
return LoginStatus.CONNECTION_FAILED; return LoginStatus.CONNECTION_FAILED;
} catch (JSONException e) { } catch (JSONException e) {
Log.e(NotesClientUtil.class.getSimpleName(), "Exception", e);
return LoginStatus.JSON_FAILED; return LoginStatus.JSON_FAILED;
} }
} }