Skip to content

Commit c144dfe

Browse files
authored
[EH] Avoid including the exception pointer within the assert info (#18784)
1 parent 67cee0b commit c144dfe

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

site/source/docs/porting/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ the output:
2828
.. code-block:: text
2929
3030
throw...
31-
exception thrown: 5246024 - Exception catching is disabled, this exception cannot be caught. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.
31+
Aborted(Assertion failed: Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.)
3232
3333
If you want to opt-in, you have two following options.
3434

src/parseTools.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,11 @@ function makeReturn64(value) {
489489

490490
function makeThrow(excPtr) {
491491
if (ASSERTIONS && DISABLE_EXCEPTION_CATCHING) {
492-
excPtr += ' + " - Exception catching is disabled, this exception cannot be caught. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch."';
492+
var assertInfo = 'Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.';
493493
if (MAIN_MODULE) {
494-
excPtr += ' + " (note: in dynamic linking, if a side module wants exceptions, the main module must be built with that support)"';
494+
assertInfo += ' (note: in dynamic linking, if a side module wants exceptions, the main module must be built with that support)';
495495
}
496-
return `throw ${excPtr};`;
496+
return `assert(false, '${assertInfo}');`;
497497
}
498498
if (EXCEPTION_STACK_TRACES) {
499499
return `throw new CppException(${excPtr});`;

test/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6763,7 +6763,7 @@ def build_main(args):
67636763

67646764
build_main([])
67656765
out = self.run_js('a.out.js', assert_returncode=NON_ZERO)
6766-
self.assertContained('Exception catching is disabled, this exception cannot be caught.', out)
6766+
self.assertContained('Exception thrown, but exception catching is not enabled.', out)
67676767
self.assertContained('note: in dynamic linking, if a side module wants exceptions, the main module must be built with that support', out)
67686768

67696769
build_main(['-fexceptions'])

0 commit comments

Comments
 (0)