@@ -16,6 +16,7 @@ import { NATIVE } from './wrapper';
1616import { Screenshot } from './integrations/screenshot' ;
1717import { NativescriptTracing } from './tracing' ;
1818import { rewriteFrameIntegration } from './integrations/default' ;
19+ import { parseErrorStack } from './integrations/debugsymbolicator' ;
1920
2021
2122/**
@@ -52,18 +53,38 @@ export class NativescriptClient extends BaseClient<NativescriptClientOptions> {
5253 /**
5354 * @inheritDoc
5455 */
55- public eventFromException ( exception : unknown , hint ?: EventHint ) : PromiseLike < Event > {
56+ public async eventFromException ( exception : unknown , hint ?: EventHint ) : Promise < Event > {
5657 // N put stackTrace in "stackTrace" instead of "stacktrace"
57- if ( exception [ 'stackTrace' ] ) {
58+ if ( exception [ 'nativeException' ] ) {
59+ // in case of nativeException we have:
60+ // - stack with only the JS error stack
61+ // stackTrace with a mix of JS/Java error
62+ exception [ 'stacktrace' ] = exception . toString ( ) + '\n at ' + exception [ 'stack' ] ;
63+ // console.log('eventFromException', exception['stack']);
64+ // console.log('eventFromException1', exception['stackTrace']);
65+ } else if ( exception [ 'stackTrace' ] ) {
5866 exception [ 'stacktrace' ] = exception [ 'stackTrace' ] ;
5967 }
6068 const hintWithScreenshot = Screenshot . attachScreenshotToEventHint ( hint , this . _options ) ;
61- return eventFromException (
69+ const event = await eventFromException (
6270 this . _options . stackParser ,
6371 exception ,
6472 hintWithScreenshot ,
6573 this . _options . attachStacktrace ,
6674 ) ;
75+ if ( exception [ 'nativeException' ] ) {
76+ const stack = parseErrorStack ( { stack : 'at ' + exception [ 'stackTrace' ] } as any ) . filter ( f => f . platform !== 'javascript' ) ;
77+ stack . forEach ( ( frame ) => rewriteFrameIntegration . _iteratee ( frame ) ) ;
78+ event . exception . values . unshift ( {
79+ type :'NativeException' ,
80+ value :exception . toString ( ) ,
81+ stacktrace :{
82+ frames :stack
83+ }
84+ } ) ;
85+ }
86+ // event.exception.values.forEach(ex=>console.log('event.exception.values', JSON.stringify(ex.stacktrace.frames.reverse())));
87+ return event ;
6788 // return this._browserClient.eventFromException(exception, hint);
6889 }
6990
@@ -78,7 +99,8 @@ export class NativescriptClient extends BaseClient<NativescriptClientOptions> {
7899 hint ,
79100 this . _options . attachStacktrace ,
80101 ) . then ( ( event : Event ) => {
81- // TMP! Remove this function once JS SDK uses threads for messages
102+ console . log ( 'eventFromMessage' ) ;
103+ // TMP! Remove this function once JS SDK uses threads for messages
82104 if ( ! event . exception ?. values || event . exception . values . length <= 0 ) {
83105 return event ;
84106 }
0 commit comments