mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
feat(compat): add .code to dyn import error (#12633)
This commit is contained in:
parent
3828a7eb11
commit
8e010b6844
4 changed files with 16 additions and 0 deletions
|
@ -23,6 +23,11 @@ itest!(compat_with_import_map_and_https_imports {
|
|||
output: "compat/import_map_https_imports.out",
|
||||
});
|
||||
|
||||
itest!(compat_dyn_import_rejects_with_node_compatible_error {
|
||||
args: "run --quiet --compat --unstable -A compat/dyn_import_reject.js",
|
||||
output: "compat/dyn_import_reject.out",
|
||||
});
|
||||
|
||||
#[test]
|
||||
fn globals_in_repl() {
|
||||
let (out, _err) = util::run_and_collect_output_with_args(
|
||||
|
|
4
cli/tests/testdata/compat/dyn_import_reject.js
vendored
Normal file
4
cli/tests/testdata/compat/dyn_import_reject.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
import("./foobar.js").catch((e) => {
|
||||
console.log(e);
|
||||
console.log(e.code);
|
||||
});
|
2
cli/tests/testdata/compat/dyn_import_reject.out
vendored
Normal file
2
cli/tests/testdata/compat/dyn_import_reject.out
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
TypeError: Cannot load module "file:///[WILDCARD]/testdata/compat/foobar.js".
|
||||
ERR_MODULE_NOT_FOUND
|
|
@ -244,6 +244,11 @@ pub extern "C" fn host_import_module_dynamically_callback(
|
|||
let message = arg.get(scope, message_key.into()).unwrap();
|
||||
let exception =
|
||||
v8::Exception::type_error(scope, message.try_into().unwrap());
|
||||
let code_key = v8::String::new(scope, "code").unwrap();
|
||||
let code_value =
|
||||
v8::String::new(scope, "ERR_MODULE_NOT_FOUND").unwrap();
|
||||
let exception_obj = exception.to_object(scope).unwrap();
|
||||
exception_obj.set(scope, code_key.into(), code_value.into());
|
||||
scope.throw_exception(exception);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue