2016-10-19 37 views
1

在本地做出反應源代碼DevSupportManagerImpl.java有這樣的代碼:如何捕獲Android應用程序中的所有React Native異常?

@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是假的(發行版),如何捕捉在Java代碼中的異常?

+0

比如,當我從服務器加載客戶包文件中,init可能會崩潰(程序跳轉到handleException人),因爲客戶包文件可能壞。 – yan

回答

0

我認爲應該使用Crashlytics。爲了更好的理解,請檢查下面的談話在github上

Handling React Native Exceptions

+0

TKS,但我想趕上初始化異常(熱負載包文件),當捕獲這個異常,將跳轉到網頁。 – yan

相關問題