Skip to content

[EmscriptenEH] Always use custom JS class for C/C++ exceptions#26523

Merged
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:emscripten_exception_classes
Mar 24, 2026
Merged

[EmscriptenEH] Always use custom JS class for C/C++ exceptions#26523
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:emscripten_exception_classes

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Mar 23, 2026

This has a slight codesize cost but it means we no longer have to worry about the ambiguity in when we catch a Number.

@sbc100 sbc100 requested a review from aheejin March 23, 2026 19:10
@sbc100 sbc100 force-pushed the emscripten_exception_classes branch from a6a0939 to 0f4b37a Compare March 23, 2026 19:10
@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 23, 2026

I took a stab at what we discussed in today's meeting..

@sbc100 sbc100 requested a review from kripken March 23, 2026 19:11
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe this is worth it for the simplicity.

Copy link
Member

@aheejin aheejin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

_emval_throw: (object) => {
object = Emval.toValue(object);
#if !WASM_EXCEPTIONS
#if !WASM_EXCEPTIONS && !DISABLE_EXCEPTION_CATCHING
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the latter be !DISABLE_EXCEPTION_THROWING? We allow throwing exceptions even when DISABLE_EXCEPTION_CATCHING is true. We should be throwing CppException and not a number in that case too, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I believe that then catching is disabled we just abort instead of throwing so there should be nothing to actually throw.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT @aheejin , OK to land this? Tests seems happy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, forgot that we call abort in that case. LGTM

@sbc100 sbc100 force-pushed the emscripten_exception_classes branch 2 times, most recently from 0a897cd to 2d33bff Compare March 23, 2026 22:03
@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 23, 2026

I could split this PR up into smaller ones if you prefer?

This has a slight codesize cost but it means we no longer have to worry
about the ambiguity in when we catch a Number.
@sbc100 sbc100 force-pushed the emscripten_exception_classes branch from 2d33bff to 10ae340 Compare March 23, 2026 22:16
@sbc100 sbc100 merged commit 5967d73 into emscripten-core:main Mar 24, 2026
38 checks passed
@sbc100 sbc100 deleted the emscripten_exception_classes branch March 24, 2026 00:11
aheejin added a commit to aheejin/emscripten that referenced this pull request Mar 24, 2026
This is not necessarily anymore after emscripten-core#26523.
aheejin added a commit that referenced this pull request Mar 24, 2026
This is not necessarily anymore after #26523.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants