Wrap JS published by %%javascript in try/catch#2199
Conversation
|
In terms of the error message, I would say 'browser' is more clear than 'frontend'. Anyone using something other than a browser probably knows enough to work out where to look for errors. |
|
fixed. |
|
There is no difference between javascript from |
|
IMHO, the use of |
|
Also, how can this prevent notebooks from loading? displayed JS is not run when a notebook is first loaded. |
|
Am I mistaking displayed JS with markdown JS ? |
|
Yes, I think so - markdown js is totally unprotected, and can bork the whole thing (something we really should protect against). Errors in your JS (%%javascript or display(JS)) don't seem to be able to cause any problems, at load time or run time. |
|
Moved logic into |
|
Are you sure it belongs in the JS object, and not the frontend itself? |
|
I don't wan't to force people to publish protected javascript, or at least give them a way to disable it. |
|
So do we implement this one in kernel or in frontend ? |
|
#2212 protects markdown cells from javascript errors. Personally, I don't think display(JS) needs any protecting, since I don't think it can actually cause problems, can it? |
|
it still warns you that you made a mistake ... |
|
Would you like ipython to catch you traceback ? |
|
That's a good point. I imagine some folks would like a traceback. |
|
Made on browser side only. |
There was a problem hiding this comment.
Let's use a CSS class here ('js-error'?), instead of direct attrs.
There was a problem hiding this comment.
when yours is merged, i'll do
.render-error, .js-error{
...
}
For now, I'll go to sleep.
There was a problem hiding this comment.
Seems like render-error in the other branch should be called js-error. Aren't they really the same thing?
There was a problem hiding this comment.
Yes, I will change that one to match.
-MinRK
On Jul 27, 2012, at 17:28, "Brian E. Granger"[email protected] wrote:
@@ -360,7 +360,19 @@ var IPython = (function (IPython) {
container.hide();
// If the Javascript appends content toelementthat should be drawn, then
// it must also callcontainer.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.').attr('style','color:darkred')Seems like
render-errorin the other branch should be calledjs-error. Aren't they really the same thing?
Reply to this email directly or view it on GitHub:
https://github.com/ipython/ipython/pull/2199/files#r1257667
|
ok, rebase on top on Min's one that catch js in markdown. I'll merge. |
Wrap published javascript in try/catch to show a error if it raises.
Wrap published javascript in try/catch to show a error if it raises.
by default %%javascript will publish it's content in a try/catch and
display a warning in cell output if the expression raises.
This is should prevent some sneeky JS to prevent notebook to load.
and give more feedback to the user.
shows