Skip to content

Commit

Permalink
fix(android): add safe null checks and use current thread to report r…
Browse files Browse the repository at this point in the history
…un-time errors
  • Loading branch information
prashantsaini1 committed Feb 17, 2025
1 parent d5ab787 commit 6550761
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ public boolean handleMessage(Message msg)
}
}
} catch (Throwable t) {
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(null, t);
TiApplication.handleInternalException(t);
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ public void loadAppProperties()
}
}

public static void handleInternalException(Throwable throwable)
{
final UncaughtExceptionHandler currentExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
if (currentExceptionHandler != null) {
currentExceptionHandler.uncaughtException(Thread.currentThread(), throwable);
}
}

@Override
public void onCreate()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ public void onChanged(TiActivitySafeAreaMonitor monitor)
try {
windowCreated(savedInstanceState);
} catch (Throwable t) {
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(null, t);
TiApplication.handleInternalException(t);
}

// set the current activity back to what it was originally
Expand All @@ -817,7 +817,7 @@ public void onChanged(TiActivitySafeAreaMonitor monitor)
try {
window.onWindowActivityCreated();
} catch (Throwable t) {
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(null, t);
TiApplication.handleInternalException(t);
}
}
if (activityProxy != null) {
Expand Down Expand Up @@ -1338,7 +1338,7 @@ private void dispatchCallback(String propertyName, KrollDict data)
data.put(TiC.EVENT_PROPERTY_SOURCE, this.activityProxy);
this.activityProxy.callPropertySync(propertyName, new Object[] { data });
} catch (Throwable ex) {
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(null, ex);
TiApplication.handleInternalException(ex);
}
}

Expand Down

0 comments on commit 6550761

Please sign in to comment.