summaryrefslogtreecommitdiff
path: root/core/error_builder_test.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/error_builder_test.js')
-rw-r--r--core/error_builder_test.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/error_builder_test.js b/core/error_builder_test.js
new file mode 100644
index 000000000..aae47c6cd
--- /dev/null
+++ b/core/error_builder_test.js
@@ -0,0 +1,30 @@
+const { core } = Deno;
+
+class DOMException {
+ constructor(message, code) {
+ this.msg = message;
+ this.code = code;
+ }
+}
+
+core.registerErrorBuilder(
+ "DOMExceptionOperationError",
+ function DOMExceptionOperationError(msg) {
+ return new DOMException(msg, "OperationError");
+ },
+);
+
+try {
+ core.opSync("op_err", undefined, null);
+ throw new Error("op_err didn't throw!");
+} catch (err) {
+ if (!(err instanceof DOMException)) {
+ throw new Error("err not DOMException");
+ }
+ if (err.msg !== "abc") {
+ throw new Error("err.message is incorrect");
+ }
+ if (err.code !== "OperationError") {
+ throw new Error("err.code is incorrect");
+ }
+}