summaryrefslogtreecommitdiff
path: root/tests/error_014_catch_dynamic_import_error.js
blob: ad3735fc3907b11f5e6234095ad074569d97a1ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(async () => {
  try {
    await import("does not exist");
  } catch (err) {
    console.log("Caught direct dynamic import error.");
    console.log(err);
  }

  try {
    await import("./subdir/indirect_import_error.js");
  } catch (err) {
    console.log("Caught indirect direct dynamic import error.");
    console.log(err);
  }

  try {
    await import("./subdir/throws.js");
  } catch (err) {
    console.log("Caught error thrown by dynamically imported module.");
    console.log(err);
  }

  try {
    await import("./subdir/indirect_throws.js");
  } catch (err) {
    console.log(
      "Caught error thrown indirectly by dynamically imported module."
    );
    console.log(err);
  }
})();