Skip to content
Snippets Groups Projects
Commit c6b8b538 authored by Arkerthan's avatar Arkerthan
Browse files

Give out nice error instead of failing horribly in domPassage.render()

parent f36a07d4
No related branches found
No related tags found
1 merge request!8562Give out nice error instead of failing horribly in domPassage.render()
...@@ -21,6 +21,25 @@ App.DomPassage = class extends Passage { ...@@ -21,6 +21,25 @@ App.DomPassage = class extends Passage {
* @returns {Node} * @returns {Node}
*/ */
render() { render() {
return this.callback(); // In case the callback fails give out a nice error message instead of breaking completely.
try {
return this.callback();
} catch (ex) {
const fragment = document.createDocumentFragment();
App.UI.DOM.appendNewElement("p", fragment, `${ex.name}: ${ex.message}`, ["bold", "error"]);
const p = document.createElement("p");
const lines = ex.stack.split("\n");
for (const ll of lines) {
const div = document.createElement("div");
// remove file path from error message
div.append(ll.replace(/file:.*\//, "<path>/"));
p.append(div);
}
fragment.append(p);
return fragment;
}
} }
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment