@@ -16,6 +16,7 @@ import { NATIVE } from './wrapper';
16
16
import { Screenshot } from './integrations/screenshot' ;
17
17
import { NativescriptTracing } from './tracing' ;
18
18
import { rewriteFrameIntegration } from './integrations/default' ;
19
+ import { parseErrorStack } from './integrations/debugsymbolicator' ;
19
20
20
21
21
22
/**
@@ -52,18 +53,38 @@ export class NativescriptClient extends BaseClient<NativescriptClientOptions> {
52
53
/**
53
54
* @inheritDoc
54
55
*/
55
- public eventFromException ( exception : unknown , hint ?: EventHint ) : PromiseLike < Event > {
56
+ public async eventFromException ( exception : unknown , hint ?: EventHint ) : Promise < Event > {
56
57
// 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' ] ) {
58
66
exception [ 'stacktrace' ] = exception [ 'stackTrace' ] ;
59
67
}
60
68
const hintWithScreenshot = Screenshot . attachScreenshotToEventHint ( hint , this . _options ) ;
61
- return eventFromException (
69
+ const event = await eventFromException (
62
70
this . _options . stackParser ,
63
71
exception ,
64
72
hintWithScreenshot ,
65
73
this . _options . attachStacktrace ,
66
74
) ;
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 ;
67
88
// return this._browserClient.eventFromException(exception, hint);
68
89
}
69
90
@@ -78,7 +99,8 @@ export class NativescriptClient extends BaseClient<NativescriptClientOptions> {
78
99
hint ,
79
100
this . _options . attachStacktrace ,
80
101
) . 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
82
104
if ( ! event . exception ?. values || event . exception . values . length <= 0 ) {
83
105
return event ;
84
106
}
0 commit comments