mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
31 lines
661 B
JavaScript
31 lines
661 B
JavaScript
|
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");
|
||
|
}
|
||
|
}
|