##// END OF EJS Templates
Merge pull request #4136 from minrk/catch-js...
Min RK -
r12438:fbc27192 merge
parent child Browse files
Show More
@@ -312,6 +312,33 b' var IPython = (function (IPython) {'
312 312 }
313 313 return oa;
314 314 };
315
316 OutputArea.prototype._append_javascript_error = function (err, container) {
317 // display a message when a javascript error occurs in display output
318 var msg = "Javascript error adding output!"
319 console.log(msg, err);
320 if ( container === undefined ) return;
321 container.append(
322 $('<div/>').html(msg + "<br/>" +
323 err.toString() +
324 '<br/>See your browser Javascript console for more details.'
325 ).addClass('js-error')
326 );
327 container.show();
328 };
329
330 OutputArea.prototype._safe_append = function (toinsert) {
331 // safely append an item to the document
332 // this is an object created by user code,
333 // and may have errors, which should not be raised
334 // under any circumstances.
335 try {
336 this.element.append(toinsert);
337 } catch(err) {
338 console.log(err);
339 this._append_javascript_error(err, this.element);
340 }
341 };
315 342
316 343
317 344 OutputArea.prototype.append_pyout = function (json, dynamic) {
@@ -321,19 +348,7 b' var IPython = (function (IPython) {'
321 348 toinsert.find('div.prompt').addClass('output_prompt').html('Out[' + n + ']:');
322 349 }
323 350 this.append_mime_type(json, toinsert, dynamic);
324 try {
325 this.element.append(toinsert);
326 } catch(err) {
327 console.log("Error attaching output!");
328 console.log(err);
329 this.element.show();
330 toinsert.html($('<div/>')
331 .html("Javascript error adding output!<br/>" +
332 err.toString() +
333 '<br/>See your browser Javascript console for more details.')
334 .addClass('js-error')
335 );
336 }
351 this._safe_append(toinsert);
337 352 // If we just output latex, typeset it.
338 353 if ((json.latex !== undefined) || (json.html !== undefined)) {
339 354 this.typeset();
@@ -352,7 +367,7 b' var IPython = (function (IPython) {'
352 367 s = s + '\n';
353 368 var toinsert = this.create_output_area();
354 369 this.append_text(s, {}, toinsert);
355 this.element.append(toinsert);
370 this._safe_append(toinsert);
356 371 }
357 372 };
358 373
@@ -389,14 +404,14 b' var IPython = (function (IPython) {'
389 404 // If we got here, attach a new div
390 405 var toinsert = this.create_output_area();
391 406 this.append_text(text, {}, toinsert, "output_stream "+subclass);
392 this.element.append(toinsert);
407 this._safe_append(toinsert);
393 408 };
394 409
395 410
396 411 OutputArea.prototype.append_display_data = function (json, dynamic) {
397 412 var toinsert = this.create_output_area();
398 413 this.append_mime_type(json, toinsert, dynamic);
399 this.element.append(toinsert);
414 this._safe_append(toinsert);
400 415 // If we just output latex, typeset it.
401 416 if ( (json.latex !== undefined) || (json.html !== undefined) ) {
402 417 this.typeset();
@@ -444,15 +459,7 b' var IPython = (function (IPython) {'
444 459 try {
445 460 eval(js);
446 461 } catch(err) {
447 console.log('Error in Javascript!');
448 console.log(err);
449 container.show();
450 element.append($('<div/>')
451 .html("Error in Javascript !<br/>"+
452 err.toString()+
453 '<br/>See your browser Javascript console for more details.')
454 .addClass('js-error')
455 );
462 this._append_javascript_error(err, container);
456 463 }
457 464 };
458 465
General Comments 0
You need to be logged in to leave comments. Login now