Skip to content

Commit e0bbb89

Browse files
committed
add @throws annotations
1 parent de31941 commit e0bbb89

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/widget.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class Widget {
195195
/**
196196
* Save all interactive DOM elements as variables for later access.
197197
*
198+
* @throws {Error} If parent container element not found
198199
* @private
199200
*/
200201
setupElements () {
@@ -263,6 +264,7 @@ class Widget {
263264
* otherwise it will be appended to the document's body.
264265
*
265266
* @param {String,HTMLElement} [element] - Widget's parent
267+
* @throws {Error} If the element is not found or is of an unknown type.
266268
*/
267269
attach (element) {
268270
const domElement = this.createHtmlTemplate(element);
@@ -274,10 +276,10 @@ class Widget {
274276
} else if (typeof element === "string") {
275277
this.parentContainerEl = document.getElementById(element);
276278
if (!parent) {
277-
throw Error("Failed to find target DOM element with id=\"" + element + "\"");
279+
throw new Error("Failed to find target DOM element with id=\"" + element + "\"");
278280
}
279281
} else if (element) {
280-
throw Error("Unknown element type. Expected instance of HTMLElement or type of string.");
282+
throw new Error("Unknown element type. Expected instance of HTMLElement or type of string.");
281283
} else {
282284
this.parentContainerEl = document.body;
283285
}

0 commit comments

Comments
 (0)