Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lib: small refactoring around js exception printing #1743

Merged
merged 1 commit into from
Nov 25, 2024
Merged

Conversation

hhugo
Copy link
Member

@hhugo hhugo commented Nov 25, 2024

No description provided.

@hhugo hhugo merged commit 44ef0bb into master Nov 25, 2024
18 of 21 checks passed
@hhugo hhugo deleted the lib-cleanup branch November 25, 2024 14:26
@TyOverby
Copy link
Collaborator

Does this change any semantics?

@hhugo
Copy link
Member Author

hhugo commented Nov 25, 2024

Previously, We would call toString to print any value that doesn't look like an OCaml exception.
With this PR, the printer only looks for js Errors.

So yes, there is a semantic difference. It was extracted from the wasm backend branch. Maybe @vouillon can tell if/why it is necessary for the wasm backend.

@vouillon
Copy link
Member

If the value was an JavaScript array, we would consider it as an OCaml exception. Otherwise, we would use toString to turn get an error message, assuming that it was a JavaScript exception. Since does not work with wasm_of_ocaml, since OCaml exceptions are Wasm arrays, which are not JavaScript array and does not have a toString method. With this change, we instead test whether the value is a JavaScript exception.

I'm not sure we still need this code, actually. We now call caml_wrap_exception systematically to turn JavaScript exceptions into OCaml exceptions, so this code should never see any JavaScript exception.

vouillon pushed a commit to OlivierNicole/js_of_ocaml that referenced this pull request Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants