diff --git a/src/lib/libexceptions.js b/src/lib/libexceptions.js index c3a05a763e819..6e402da2f3fc5 100644 --- a/src/lib/libexceptions.js +++ b/src/lib/libexceptions.js @@ -384,25 +384,14 @@ var LibraryExceptions = { }, #elif !DISABLE_EXCEPTION_CATCHING - // When EXCEPTION_STACK_TRACES is set, the exception is an instance of - // CppException, whereas EXCEPTION_STACK_TRACES is unset it is a raw pointer. - $exnToPtr: (exn) => { -#if EXCEPTION_STACK_TRACES - if (exn instanceof CppException) { - return exn.excPtr; - } -#endif - return exn; - }, - - $incrementExceptionRefcount__deps: ['$exnToPtr', '__cxa_increment_exception_refcount'], - $incrementExceptionRefcount: (exn) => ___cxa_increment_exception_refcount(exnToPtr(exn)), + $incrementExceptionRefcount__deps: ['__cxa_increment_exception_refcount'], + $incrementExceptionRefcount: (exn) => ___cxa_increment_exception_refcount(exn.excPtr), - $decrementExceptionRefcount__deps: ['$exnToPtr', '__cxa_decrement_exception_refcount'], - $decrementExceptionRefcount: (exn) => ___cxa_decrement_exception_refcount(exnToPtr(exn)), + $decrementExceptionRefcount__deps: ['__cxa_decrement_exception_refcount'], + $decrementExceptionRefcount: (exn) => ___cxa_decrement_exception_refcount(exn.excPtr), - $getExceptionMessage__deps: ['$exnToPtr', '$getExceptionMessageCommon'], - $getExceptionMessage: (exn) => getExceptionMessageCommon(exnToPtr(exn)), + $getExceptionMessage__deps: ['$getExceptionMessageCommon'], + $getExceptionMessage: (exn) => getExceptionMessageCommon(exn.excPtr), #endif }; diff --git a/src/runtime_exceptions.js b/src/runtime_exceptions.js index 0b6aa5683354f..18a0d0f00dd3a 100644 --- a/src/runtime_exceptions.js +++ b/src/runtime_exceptions.js @@ -27,7 +27,7 @@ class CppException extends EmscriptenEH { #endif this.excPtr = excPtr; #if !DISABLE_EXCEPTION_CATCHING && EXCEPTION_STACK_TRACES - const excInfo = getExceptionMessage(excPtr); + const excInfo = getExceptionMessage(this); this.name = excInfo[0]; this.message = excInfo[1]; #endif