diff --git a/src/platform/web/ui/general/ListView.js b/src/platform/web/ui/general/ListView.js index 3ec7207c..749ae6cf 100644 --- a/src/platform/web/ui/general/ListView.js +++ b/src/platform/web/ui/general/ListView.js @@ -15,6 +15,7 @@ limitations under the License. */ import {tag} from "./html.js"; +import {errorToDOM} from "./error.js"; function insertAt(parentNode, idx, childNode) { const isLast = idx === parentNode.childElementCount; @@ -106,8 +107,12 @@ export class ListView { for (let item of this._list) { const child = this._childCreator(item); this._childInstances.push(child); - const childDomNode = child.mount(this._mountArgs); - fragment.appendChild(childDomNode); + try { + const childDomNode = child.mount(this._mountArgs); + fragment.appendChild(childDomNode); + } catch (err) { + fragment.appendChild(errorToDOM(err)); + } } this._root.appendChild(fragment); } diff --git a/src/platform/web/ui/general/error.js b/src/platform/web/ui/general/error.js index d72275fc..48728a4b 100644 --- a/src/platform/web/ui/general/error.js +++ b/src/platform/web/ui/general/error.js @@ -18,7 +18,10 @@ import {tag} from "./html.js"; export function errorToDOM(error) { const stack = new Error().stack; - const callee = stack.split("\n")[1]; + let callee = null; + if (stack) { + callee = stack.split("\n")[1]; + } return tag.div([ tag.h2("Something went wrong…"), tag.h3(error.message),