@@ -19,15 +19,9 @@ var stringifySafe = require('stringifySafe');
1919
2020var sourceMapPromise ;
2121
22- type Exception = {
23- sourceURL : string ;
24- line: number ;
25- message: string ;
26- }
27-
2822var exceptionID = 0 ;
2923
30- function reportException ( e : Exception , isFatal : bool , stack ?: any ) {
24+ function reportException ( e : Error , isFatal : bool , stack ?: any ) {
3125 var currentExceptionID = ++ exceptionID ;
3226 if ( RCTExceptionsManager ) {
3327 if ( ! stack ) {
@@ -53,13 +47,20 @@ function reportException(e: Exception, isFatal: bool, stack?: any) {
5347 }
5448}
5549
56- function handleException ( e : Exception , isFatal : boolean ) {
50+ function handleException ( e : Error , isFatal : boolean ) {
51+ // Workaround for reporting errors caused by `throw 'some string'`
52+ // Unfortunately there is no way to figure out the stacktrace in this
53+ // case, so if you ended up here trying to trace an error, look for
54+ // `throw '<error message>'` somewhere in your codebase.
55+ if ( ! e . message ) {
56+ e = new Error ( e ) ;
57+ }
5758 var stack = parseErrorStack ( e ) ;
5859 var msg =
5960 'Error: ' + e . message +
6061 '\n stack: \n' + stackToString ( stack ) +
61- '\n URL: ' + e . sourceURL +
62- '\n line: ' + e . line +
62+ '\n URL: ' + ( e : any ) . sourceURL +
63+ '\n line: ' + ( e : any ) . line +
6364 '\n message: ' + e . message ;
6465 if ( console . errorOriginal ) {
6566 console . errorOriginal ( msg ) ;
0 commit comments