@@ -58,7 +58,7 @@ private native void initNativeScript(int runtimeId, String filesPath, String nat
5858
5959 private native void unlock (int runtimeId );
6060
61- private native void passExceptionToJsNative (int runtimeId , Throwable ex , String message , String stackTrace , boolean isDiscarded );
61+ private native void passExceptionToJsNative (int runtimeId , Throwable ex , String message , String fullStackTrace , String jsStackTrace , boolean isDiscarded );
6262
6363 private native void clearStartupData (int runtimeId );
6464
@@ -78,15 +78,15 @@ private native void initNativeScript(int runtimeId, String filesPath, String nat
7878
7979 private static native void ResetDateTimeConfigurationCache (int runtimeId );
8080
81- void passUncaughtExceptionToJs (Throwable ex , String message , String stackTrace ) {
82- passExceptionToJsNative (getRuntimeId (), ex , message , stackTrace , false );
81+ void passUncaughtExceptionToJs (Throwable ex , String message , String fullStackTrace , String jsStackTrace ) {
82+ passExceptionToJsNative (getRuntimeId (), ex , message , fullStackTrace , jsStackTrace , false );
8383 }
8484
8585 void passDiscardedExceptionToJs (Throwable ex , String prefix ) {
8686 //String message = prefix + ex.getMessage();
8787 // we'd better not prefix the error with something like - Error on "main" thread for reportSupressedException
8888 // as it doesn't seem very useful for the users
89- passExceptionToJsNative (getRuntimeId (), ex , ex .getMessage (), Runtime .getStackTraceErrorMessage (ex ), true );
89+ passExceptionToJsNative (getRuntimeId (), ex , ex .getMessage (), Runtime .getStackTraceErrorMessage (ex ), Runtime . getJSStackTrace ( ex ), true );
9090 }
9191
9292 public static void passSuppressedExceptionToJs (Throwable ex , String methodName ) {
@@ -274,6 +274,14 @@ private static String getStackTraceOnly(String content) {
274274 return result ;
275275 }
276276
277+ public static String getJSStackTrace (Throwable ex ) {
278+ if (ex instanceof NativeScriptException ) {
279+ return ((NativeScriptException ) ex ).getIncomingStackTrace ();
280+ } else {
281+ return null ;
282+ }
283+ }
284+
277285 public static String getStackTraceErrorMessage (Throwable ex ) {
278286 String content ;
279287 java .io .PrintStream ps = null ;
@@ -285,9 +293,10 @@ public static String getStackTraceErrorMessage(Throwable ex) {
285293
286294 try {
287295 content = baos .toString ("UTF-8" );
288- if (ex instanceof NativeScriptException ) {
296+ String jsStackTrace = Runtime .getJSStackTrace (ex );
297+ if (jsStackTrace != null ) {
289298 content = getStackTraceOnly (content );
290- content = (( NativeScriptException ) ex ). getIncomingStackTrace () + content ;
299+ content = jsStackTrace + content ;
291300 }
292301 } catch (java .io .UnsupportedEncodingException e ) {
293302 content = e .getMessage ();
0 commit comments