@@ -58,7 +58,7 @@ private native void initNativeScript(int runtimeId, String filesPath, String nat
58
58
59
59
private native void unlock (int runtimeId );
60
60
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 );
62
62
63
63
private native void clearStartupData (int runtimeId );
64
64
@@ -78,15 +78,15 @@ private native void initNativeScript(int runtimeId, String filesPath, String nat
78
78
79
79
private static native void ResetDateTimeConfigurationCache (int runtimeId );
80
80
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 );
83
83
}
84
84
85
85
void passDiscardedExceptionToJs (Throwable ex , String prefix ) {
86
86
//String message = prefix + ex.getMessage();
87
87
// we'd better not prefix the error with something like - Error on "main" thread for reportSupressedException
88
88
// 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 );
90
90
}
91
91
92
92
public static void passSuppressedExceptionToJs (Throwable ex , String methodName ) {
@@ -274,6 +274,14 @@ private static String getStackTraceOnly(String content) {
274
274
return result ;
275
275
}
276
276
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
+
277
285
public static String getStackTraceErrorMessage (Throwable ex ) {
278
286
String content ;
279
287
java .io .PrintStream ps = null ;
@@ -285,9 +293,10 @@ public static String getStackTraceErrorMessage(Throwable ex) {
285
293
286
294
try {
287
295
content = baos .toString ("US-ASCII" );
288
- if (ex instanceof NativeScriptException ) {
296
+ String jsStackTrace = Runtime .getJSStackTrace (ex );
297
+ if (jsStackTrace != null ) {
289
298
content = getStackTraceOnly (content );
290
- content = (( NativeScriptException ) ex ). getIncomingStackTrace () + content ;
299
+ content = jsStackTrace + content ;
291
300
}
292
301
} catch (java .io .UnsupportedEncodingException e ) {
293
302
content = e .getMessage ();
0 commit comments