-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat(compat): add .code to dyn import error #12633
Conversation
a5dd20c
to
7cda7c3
Compare
|
7cda7c3
to
8529adc
Compare
8529adc
to
a4aec92
Compare
Now ready for review I first tried to reuse class_name of CustomError for accessing the custom js error constructor, but that didn't work because some errors cause panic during getting error class (caused by |
Please discuss this change in the design letting before landing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not in favor of this Deno.compat.errors
namespace. In node await import("xxxxxx")
throws a regular Error
(no subclass), with a .code
on it. In the browser it throws a TypeError
. I think we should always throw a TypeError
(also in non-compat mode), and in compat mode add a code
property to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
part of #12577, closes #12588
This PR changes the error class for dynamic import rejection in compat mode. Some tools (e.g. mocha) uses .code property of error object to detect the resolution failure of dynamic import (ref: https://github.com/mochajs/mocha/blob/97b84708afb42e552cb906a54f9f2aa2e6a98ba4/lib/nodejs/esm-utils.js#L47-L56 ). This change simulates the above behavior in compat mode.
This change enables compat mode to run the basic feature of mocha cli