diff --git a/app/src/main/java/com/trianguloy/urlchecker/activities/BackupActivity.java b/app/src/main/java/com/trianguloy/urlchecker/activities/BackupActivity.java index 002ca21e..f1be11fe 100644 --- a/app/src/main/java/com/trianguloy/urlchecker/activities/BackupActivity.java +++ b/app/src/main/java/com/trianguloy/urlchecker/activities/BackupActivity.java @@ -338,8 +338,7 @@ private void restorePreferencesMatching(String fileName, Function AndroidUtils.assertError("Unknown type: " + type); } } catch (JSONException e) { - AndroidUtils.assertError("Error when restoring key: " + key); - e.printStackTrace(); + AndroidUtils.assertError("Error when restoring key: " + key, e); } } diff --git a/app/src/main/java/com/trianguloy/urlchecker/dialogs/MainDialog.java b/app/src/main/java/com/trianguloy/urlchecker/dialogs/MainDialog.java index 50517511..0c134ae2 100644 --- a/app/src/main/java/com/trianguloy/urlchecker/dialogs/MainDialog.java +++ b/app/src/main/java/com/trianguloy/urlchecker/dialogs/MainDialog.java @@ -92,8 +92,7 @@ public void onNewUrl(UrlData newUrlData) { try { module.onPrepareUrl(urlData); } catch (Exception e) { - e.printStackTrace(); - AndroidUtils.assertError("Exception in onPrepareUrl for module " + module.getClass().getName()); + AndroidUtils.assertError("Exception in onPrepareUrl for module " + module.getClass().getName(), e); } } @@ -122,8 +121,7 @@ public void onNewUrl(UrlData newUrlData) { continue main_loop; } } catch (Exception e) { - e.printStackTrace(); - AndroidUtils.assertError("Exception in onModifyUrl for module " + module.getClass().getName()); + AndroidUtils.assertError("Exception in onModifyUrl for module " + module.getClass().getName(), e); } } @@ -134,8 +132,7 @@ public void onNewUrl(UrlData newUrlData) { try { module.onDisplayUrl(urlData); } catch (Exception e) { - e.printStackTrace(); - AndroidUtils.assertError("Exception in onDisplayUrl for module " + module.getClass().getName()); + AndroidUtils.assertError("Exception in onDisplayUrl for module " + module.getClass().getName(), e); } } @@ -146,8 +143,7 @@ public void onNewUrl(UrlData newUrlData) { try { module.onFinishUrl(urlData); } catch (Exception e) { - e.printStackTrace(); - AndroidUtils.assertError("Exception in onFinishUrl for module " + module.getClass().getName()); + AndroidUtils.assertError("Exception in onFinishUrl for module " + module.getClass().getName(), e); } } @@ -312,8 +308,7 @@ private void initializeModule(AModuleData moduleData, boolean drawer) { module.onInitialize(child); } catch (Exception e) { // can't add module - e.printStackTrace(); - AndroidUtils.assertError("Exception in initializeModule for module " + moduleData.getId()); + AndroidUtils.assertError("Exception in initializeModule for module " + moduleData.getId(), e); } } diff --git a/app/src/main/java/com/trianguloy/urlchecker/modules/companions/ClearUrlCatalog.java b/app/src/main/java/com/trianguloy/urlchecker/modules/companions/ClearUrlCatalog.java index 26547397..aa6595dd 100644 --- a/app/src/main/java/com/trianguloy/urlchecker/modules/companions/ClearUrlCatalog.java +++ b/app/src/main/java/com/trianguloy/urlchecker/modules/companions/ClearUrlCatalog.java @@ -114,7 +114,7 @@ public static List> getRules(Activity cntx) { return rules; } catch (JSONException e) { // invalid catalog, return empty - AndroidUtils.assertError(e.getMessage()); + AndroidUtils.assertError(e.getMessage(), e); return Collections.emptyList(); } } diff --git a/app/src/main/java/com/trianguloy/urlchecker/utilities/methods/AndroidUtils.java b/app/src/main/java/com/trianguloy/urlchecker/utilities/methods/AndroidUtils.java index 38b3b1ea..72848198 100644 --- a/app/src/main/java/com/trianguloy/urlchecker/utilities/methods/AndroidUtils.java +++ b/app/src/main/java/com/trianguloy/urlchecker/utilities/methods/AndroidUtils.java @@ -43,14 +43,17 @@ static void setEnabled(View view, boolean enabled) { view.setAlpha(enabled ? 1f : 0.35f); } - /** - * In debug mode, throws an AssertionError, in production just logs it and continues. - */ + /** In debug mode, throws an AssertionError, in production just logs it and continues. */ static void assertError(String detailMessage) { - Log.d("ASSERT_ERROR", detailMessage); + assertError(detailMessage, null); + } + + /** In debug mode, throws an AssertionError, in production just logs it and continues. */ + static void assertError(String detailMessage, Throwable cause) { + Log.d("ASSERT_ERROR", detailMessage, cause); if (BuildConfig.DEBUG) { // in debug mode, throw exception - throw new AssertionError(detailMessage); + throw new AssertionError(detailMessage, cause); } // non-debug, just discard } @@ -172,8 +175,11 @@ static void toggleableListener(V view, JavaUtils.Consumer to static void longTapForDescription(View view) { view.setOnLongClickListener(v -> { var contentDescription = v.getContentDescription(); - if (contentDescription == null) AndroidUtils.assertError("No content description for view " + view); - Toast.makeText(v.getContext(), contentDescription, Toast.LENGTH_SHORT).show(); + if (contentDescription == null) { + AndroidUtils.assertError("No content description for view " + view); + } else { + Toast.makeText(v.getContext(), contentDescription, Toast.LENGTH_SHORT).show(); + } return true; }); }