在React Native源代码DevSupportManagerImpl.java中有以下代码:
@Override
public void handleException(Exception e) {
if (mIsDevSupportEnabled) {
if (e instanceof JSException) {
FLog.e(ReactConstants.TAG, "Exception in native call from JS", e);
// TODO #11638796: convert the stack into something useful
showNewError(e.getMessage() + "\n\n" + ((JSException) e).getStack(), new StackFrame[] {},
JSEXCEPTION_ERROR_COOKIE, ErrorType.JS);
} else {
showNewJavaError(e.getMessage(), e);
}
} else {
mDefaultNativeModuleCallExceptionHandler.handleException(e);
}
}
当mIsDevSupportEnabled为false(发布版本)时,如何捕获java代码中的异常?