summaryrefslogtreecommitdiff
path: root/cli/tests/testdata
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2022-08-21 19:16:42 +0100
committerGitHub <noreply@github.com>2022-08-21 20:16:42 +0200
commit97954003cc87b664768918173e8d00f6df35e04f (patch)
treedcad94ac57503ba56e8cd14847cc60b1c2ddc91c /cli/tests/testdata
parente96933bc163fd81a276cbc169b17f76724a5ac33 (diff)
feat: `queueMicrotask()` error handling (#15522)
Adds error event dispatching for queueMicrotask(). Consequently unhandled errors are now reported with Deno.core.terminate(), which is immune to the existing quirk with plainly thrown errors (#14158).
Diffstat (limited to 'cli/tests/testdata')
-rw-r--r--cli/tests/testdata/queue_microtask_error.ts5
-rw-r--r--cli/tests/testdata/queue_microtask_error.ts.out6
-rw-r--r--cli/tests/testdata/queue_microtask_error_handled.ts21
-rw-r--r--cli/tests/testdata/queue_microtask_error_handled.ts.out15
4 files changed, 47 insertions, 0 deletions
diff --git a/cli/tests/testdata/queue_microtask_error.ts b/cli/tests/testdata/queue_microtask_error.ts
new file mode 100644
index 000000000..b2e9642c5
--- /dev/null
+++ b/cli/tests/testdata/queue_microtask_error.ts
@@ -0,0 +1,5 @@
+queueMicrotask(() => {
+ throw new Error("foo");
+});
+console.log(1);
+Promise.resolve().then(() => console.log(2));
diff --git a/cli/tests/testdata/queue_microtask_error.ts.out b/cli/tests/testdata/queue_microtask_error.ts.out
new file mode 100644
index 000000000..6c4d41936
--- /dev/null
+++ b/cli/tests/testdata/queue_microtask_error.ts.out
@@ -0,0 +1,6 @@
+1
+error: Uncaught Error: foo
+ throw new Error("foo");
+ ^
+ at [WILDCARD]/queue_microtask_error.ts:2:9
+ at deno:core/[WILDCARD]
diff --git a/cli/tests/testdata/queue_microtask_error_handled.ts b/cli/tests/testdata/queue_microtask_error_handled.ts
new file mode 100644
index 000000000..7d1440135
--- /dev/null
+++ b/cli/tests/testdata/queue_microtask_error_handled.ts
@@ -0,0 +1,21 @@
+addEventListener("error", (event) => {
+ console.log({
+ cancelable: event.cancelable,
+ message: event.message,
+ filename: event.filename,
+ lineno: event.lineno,
+ colno: event.colno,
+ error: event.error,
+ });
+ event.preventDefault();
+});
+
+onerror = (event) => {
+ console.log("onerror() called", event.error);
+};
+
+queueMicrotask(() => {
+ throw new Error("foo");
+});
+console.log(1);
+Promise.resolve().then(() => console.log(2));
diff --git a/cli/tests/testdata/queue_microtask_error_handled.ts.out b/cli/tests/testdata/queue_microtask_error_handled.ts.out
new file mode 100644
index 000000000..7f3f7f84a
--- /dev/null
+++ b/cli/tests/testdata/queue_microtask_error_handled.ts.out
@@ -0,0 +1,15 @@
+1
+{
+ cancelable: true,
+ message: "Uncaught Error: foo",
+ filename: "[WILDCARD]/queue_microtask_error_handled.ts",
+ lineno: 18,
+ colno: 9,
+ error: Error: foo
+ at [WILDCARD]/queue_microtask_error_handled.ts:18:9
+ at deno:core/[WILDCARD]
+}
+onerror() called Error: foo
+ at [WILDCARD]/queue_microtask_error_handled.ts:18:9
+ at deno:core/[WILDCARD]
+2