refactor: remove unneeded ErrorKinds (#3936)

This commit is contained in:
Bartek Iwańczuk 2020-02-21 10:36:13 -05:00 committed by GitHub
parent d9efb8c02a
commit dd8a109481
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 553 additions and 620 deletions

View file

@ -1,6 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import * as domTypes from "./dom_types.ts";
import { DenoError, ErrorKind } from "./errors.ts";
import { hasOwnProperty, requiredArguments } from "./util.ts";
import {
getRoot,
@ -134,17 +133,15 @@ export class EventTarget implements domTypes.EventTarget {
}
if (event.dispatched || !event.initialized) {
throw new DenoError(
ErrorKind.InvalidData,
"Tried to dispatch an uninitialized event"
);
// TODO(bartlomieju): very likely that different error
// should be thrown here (DOMException?)
throw new TypeError("Tried to dispatch an uninitialized event");
}
if (event.eventPhase !== domTypes.EventPhase.NONE) {
throw new DenoError(
ErrorKind.InvalidData,
"Tried to dispatch a dispatching event"
);
// TODO(bartlomieju): very likely that different error
// should be thrown here (DOMException?)
throw new TypeError("Tried to dispatch a dispatching event");
}
return eventTargetHelpers.dispatch(this_, event);
@ -418,7 +415,9 @@ const eventTargetHelpers = {
try {
listener.handleEvent(eventImpl);
} catch (error) {
throw new DenoError(ErrorKind.Interrupted, error.message);
// TODO(bartlomieju): very likely that different error
// should be thrown here (DOMException?)
throw new Error(error.message);
}
eventImpl.inPassiveListener = false;