Merge pull request #2199 from Carreau/safe-js

Wrap published javascript in try/catch to show a error if it raises.
This commit is contained in:
Bussonnier Matthias 2012-07-28 04:09:38 -07:00
commit 99ccdf15d9

View File

@ -360,7 +360,19 @@ var IPython = (function (IPython) {
container.hide();
// If the Javascript appends content to `element` that should be drawn, then
// it must also call `container.show()`.
eval(js);
try {
eval(js);
} catch(err) {
console.log('Error in Javascript!');
console.log(err);
container.show();
element.append($('<div/>')
.html("Error in Javascript !<br/>"+
err.toString()+
'<br/>See your browser Javascript console for more details.')
.addClass('js-error')
);
}
}