File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -3274,15 +3274,22 @@ function handleFatalError(func) {
32743274 try {
32753275 return func ( ) ;
32763276 } catch ( e ) {
3277- // Fatal errors begin with that prefix. Strip it out, and the newline.
3278- // C++ exceptions are thrown as pointers (numbers) in release builds
3279- // but CppException JS class in debug builds.
3277+ // Fatal errors begin with a specific prefix. Strip it out, and the newline.
32803278 if ( typeof e === 'number' ) {
3279+ // Older version of emscripten can throw C++ exceptions as pointers
3280+ // (numbers) in release builds.
32813281 var [ _ , message ] = getExceptionMessage ( e ) ;
32823282 if ( message ?. startsWith ( 'Fatal: ' ) ) {
32833283 throw new Error ( message . substr ( 7 ) . trim ( ) ) ;
32843284 }
32853285 } else {
3286+ // Newer version of emscripten always throw CppException object but don't
3287+ // always populate the `.message` field.
3288+ // TODO: Set EXCEPTION_STACK_TRACES instead?
3289+ if ( ! e . message ) {
3290+ var [ _ , message ] = getExceptionMessage ( e ) ;
3291+ e . message = message ;
3292+ }
32863293 e . message = e . message . replace ( 'Fatal:' , '' ) ;
32873294 e . message = e . message . trim ( ) ;
32883295 }
You can’t perform that action at this time.
0 commit comments