Skip to content

Commit d003719

Browse files
authored
Merge pull request #710 from NativeScript/pete/error-activity-NPE-msg
Handle exceptions when trying to use reflection for UnhandledExceptions
2 parents 2c5e3f1 + f10584c commit d003719

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

build-artifacts/project-template-gradle/src/main/java/com/tns/NativeScriptUncaughtExceptionHandler.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,19 @@ public void uncaughtException(Thread thread, Throwable ex) {
4444
boolean res = false;
4545

4646
if (Util.isDebuggableApp(context)) {
47-
Class<?> ErrReport = null;
48-
java.lang.reflect.Method startActivity = null;
49-
5047
try {
48+
Class<?> ErrReport = null;
49+
java.lang.reflect.Method startActivity = null;
50+
5151
ErrReport = java.lang.Class.forName("com.tns.ErrorReport");
52-
} catch (ClassNotFoundException e) {
53-
android.util.Log.d("ClassNotFoundException", e.toString());
54-
}
5552

56-
try {
5753
startActivity = ErrReport.getDeclaredMethod("startActivity", android.content.Context.class, String.class);
58-
} catch (NoSuchMethodException e) {
59-
android.util.Log.d("NoSuchMethodException", e.toString());
60-
}
6154

62-
try {
6355
res = (Boolean) startActivity.invoke(null, context, errorMessage);
6456
} catch (Exception e) {
65-
android.util.Log.d("Exception", e.toString());
57+
android.util.Log.v("Error", errorMessage);
58+
e.printStackTrace();
59+
android.util.Log.v("Application Error", "ErrorActivity default implementation not found. Reinstall android platform to fix.");
6660
}
6761
}
6862

0 commit comments

Comments
 (0)