Commit 99496af5 authored by Jérome Perrin's avatar Jérome Perrin

Add an error handler

parent b0ae764c
......@@ -34,6 +34,13 @@
<li><a href="{{link}}">{{title}}</a></li>
</script>
<script id="error-template" type="text/x-handlebars-template">
<h1>An Error Has Occurred</h1>
<a href="javascript: location.reload()">Click here to reload the page</a><br/>
The error detail is:
<pre>{{error}}</pre>
</script>
</head>
<body>
......
/*global jQuery, rJS, RSVP, alert, Handlebars, initGadgetMixin */
/*global console, jQuery, rJS, RSVP, alert, Handlebars, initGadgetMixin */
/*jslint nomen: true */
(function (window, $, rJS, RSVP, Handlebars, initGadgetMixin) {
"use strict";
......@@ -155,6 +155,7 @@
panel_template,
navigation_template,
active_navigation_template,
error_template,
gadget_klass = rJS(window);
function calculateTabHTML(gadget, options, key, title, active) {
......@@ -399,6 +400,9 @@
active_navigation_template = Handlebars.compile(
document.getElementById("active-navigation-template").innerHTML
);
error_template = Handlebars.compile(
document.getElementById("error-template").innerHTML
);
}
})
......@@ -537,6 +541,13 @@
if (page_gadget.startService !== undefined) {
return page_gadget.startService();
}
}).push(undefined, function (error) {
if (error instanceof RSVP.CancellationError) {
throw error;
}
console.error(error);
document.querySelector("article[class='gadget_container']")
.innerHTML = error_template({ error: error });
});
});
}(window, jQuery, rJS, RSVP, Handlebars, initGadgetMixin));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment