##// END OF EJS Templates
Merge pull request #6303 from minrk/nbformat-error...
Thomas Kluyver -
r17644:6b260753 merge
parent child Browse files
Show More
@@ -514,15 +514,20 define([
514 }
514 }
515 };
515 };
516
516
517 var ajax_error_msg = function (jqXHR) {
518 // Return a JSON error message if there is one,
519 // otherwise the basic HTTP status text.
520 if (jqXHR.responseJSON && jqXHR.responseJSON.message) {
521 return jqXHR.responseJSON.message;
522 } else {
523 return jqXHR.statusText;
524 }
525 }
517 var log_ajax_error = function (jqXHR, status, error) {
526 var log_ajax_error = function (jqXHR, status, error) {
518 // log ajax failures with informative messages
527 // log ajax failures with informative messages
519 var msg = "API request failed (" + jqXHR.status + "): ";
528 var msg = "API request failed (" + jqXHR.status + "): ";
520 console.log(jqXHR);
529 console.log(jqXHR);
521 if (jqXHR.responseJSON && jqXHR.responseJSON.message) {
530 msg += ajax_error_msg(jqXHR);
522 msg += jqXHR.responseJSON.message;
523 } else {
524 msg += jqXHR.statusText;
525 }
526 console.log(msg);
531 console.log(msg);
527 };
532 };
528
533
@@ -547,6 +552,7 define([
547 platform: platform,
552 platform: platform,
548 is_or_has : is_or_has,
553 is_or_has : is_or_has,
549 is_focused : is_focused,
554 is_focused : is_focused,
555 ajax_error_msg : ajax_error_msg,
550 log_ajax_error : log_ajax_error,
556 log_ajax_error : log_ajax_error,
551 };
557 };
552
558
@@ -2286,13 +2286,14 define([
2286 */
2286 */
2287 Notebook.prototype.load_notebook_error = function (xhr, status, error) {
2287 Notebook.prototype.load_notebook_error = function (xhr, status, error) {
2288 this.events.trigger('notebook_load_failed.Notebook', [xhr, status, error]);
2288 this.events.trigger('notebook_load_failed.Notebook', [xhr, status, error]);
2289 utils.log_ajax_error(xhr, status, error);
2289 var msg;
2290 var msg;
2290 if (xhr.status === 400) {
2291 if (xhr.status === 400) {
2291 msg = error;
2292 msg = escape(utils.ajax_error_msg(xhr));
2292 } else if (xhr.status === 500) {
2293 } else if (xhr.status === 500) {
2293 msg = "An unknown error occurred while loading this notebook. " +
2294 msg = "An unknown error occurred while loading this notebook. " +
2294 "This version can load notebook formats " +
2295 "This version can load notebook formats " +
2295 "v" + this.nbformat + " or earlier.";
2296 "v" + this.nbformat + " or earlier. See the server log for details.";
2296 }
2297 }
2297 dialog.modal({
2298 dialog.modal({
2298 notebook: this,
2299 notebook: this,
@@ -2567,10 +2568,10 define([
2567 * @method delete_checkpoint_error
2568 * @method delete_checkpoint_error
2568 * @param {jqXHR} xhr jQuery Ajax object
2569 * @param {jqXHR} xhr jQuery Ajax object
2569 * @param {String} status Description of response status
2570 * @param {String} status Description of response status
2570 * @param {String} error_msg HTTP error message
2571 * @param {String} error HTTP error message
2571 */
2572 */
2572 Notebook.prototype.delete_checkpoint_error = function (xhr, status, error_msg) {
2573 Notebook.prototype.delete_checkpoint_error = function (xhr, status, error) {
2573 this.events.trigger('checkpoint_delete_failed.Notebook');
2574 this.events.trigger('checkpoint_delete_failed.Notebook', [xhr, status, error]);
2574 };
2575 };
2575
2576
2576
2577
@@ -80,6 +80,8 def reads(s, **kwargs):
80 nb : NotebookNode
80 nb : NotebookNode
81 The notebook that was read.
81 The notebook that was read.
82 """
82 """
83 from .current import NBFormatError
84
83 nb_dict = parse_json(s, **kwargs)
85 nb_dict = parse_json(s, **kwargs)
84 (major, minor) = get_version(nb_dict)
86 (major, minor) = get_version(nb_dict)
85 if major in versions:
87 if major in versions:
General Comments 0
You need to be logged in to leave comments. Login now