Skip to content
Snippets Groups Projects
Commit 622aa8f6 authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'error_handling' into 'pregmod-master'

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

See merge request !8562
parents fe012af4 c6b8b538
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 {
* @returns {Node}
*/
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