Show More
@@ -514,15 +514,20 b' 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 b' 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,17 +2286,14 b' 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 | if (xhr.responseJSON && xhr.responseJSON.message) { |
|
2292 | msg = escape(utils.ajax_error_msg(xhr)); | |
2292 | msg = escape(xhr.responseJSON.message); |
|
|||
2293 | } else { |
|
|||
2294 | msg = escape(error); |
|
|||
2295 | } |
|
|||
2296 | } else if (xhr.status === 500) { |
|
2293 | } else if (xhr.status === 500) { | |
2297 | msg = "An unknown error occurred while loading this notebook. " + |
|
2294 | msg = "An unknown error occurred while loading this notebook. " + | |
2298 | "This version can load notebook formats " + |
|
2295 | "This version can load notebook formats " + | |
2299 | "v" + this.nbformat + " or earlier."; |
|
2296 | "v" + this.nbformat + " or earlier. See the server log for details."; | |
2300 | } |
|
2297 | } | |
2301 | dialog.modal({ |
|
2298 | dialog.modal({ | |
2302 | notebook: this, |
|
2299 | notebook: this, |
General Comments 0
You need to be logged in to leave comments.
Login now