Commit ef9c5ce
committed
[EH] Print message for uncaught exceptions
After emscripten-core#17979, when `ASSERTIONS` is set, uncaught exceptions carry stack
traces that are printed to the screen for debugging help. This adds
an exception message to the exception objects in addition to that.
The message it adds is produced by `__get_exception_message` function:
https://github.com/emscripten-core/emscripten/blob/f6c46570e3780e52050bf822a07b342ec4bdddbe/system/lib/libcxxabi/src/cxa_exception_emscripten.cpp#L75-L111
If an exception is a subclass of `std::exception`, it returns
`std::exception::what()`. If not, it just prints its type.
If an exception is uncaught and its type is a subclass of
`std::exception`, now we print the `what()` message along with the stack
trace when `ASSERTION` is set. In case our exception is
`std::runtime_error` and the message is "my exception", when uncaught,
this prints:
```
exiting due to exception: [object WebAssembly.Exception],Error:
std::runtime_error,my exception
at __cxa_throw (wasm://wasm/009a7c9a:wasm-function[1551]:0x24367)
...
```
Fixes emscripten-core#6330.1 parent 3e53d5c commit ef9c5ce
File tree
3 files changed
+5
-3
lines changed- src
- system/lib/libcxxabi/src
3 files changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2641 | 2641 | | |
2642 | 2642 | | |
2643 | 2643 | | |
| 2644 | + | |
2644 | 2645 | | |
2645 | 2646 | | |
2646 | 2647 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| 449 | + | |
449 | 450 | | |
450 | 451 | | |
451 | 452 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| |||
0 commit comments