Show More
@@ -488,15 +488,20 b' IPython.utils = (function (IPython) {' | |||||
488 | } |
|
488 | } | |
489 | } |
|
489 | } | |
490 |
|
490 | |||
|
491 | var ajax_error_msg = function (jqXHR) { | |||
|
492 | // Return a JSON error message if there is one, | |||
|
493 | // otherwise the basic HTTP status text. | |||
|
494 | if (jqXHR.responseJSON && jqXHR.responseJSON.message) { | |||
|
495 | return jqXHR.responseJSON.message; | |||
|
496 | } else { | |||
|
497 | return jqXHR.statusText; | |||
|
498 | } | |||
|
499 | } | |||
491 | var log_ajax_error = function (jqXHR, status, error) { |
|
500 | var log_ajax_error = function (jqXHR, status, error) { | |
492 | // log ajax failures with informative messages |
|
501 | // log ajax failures with informative messages | |
493 | var msg = "API request failed (" + jqXHR.status + "): "; |
|
502 | var msg = "API request failed (" + jqXHR.status + "): "; | |
494 | console.log(jqXHR); |
|
503 | console.log(jqXHR); | |
495 | if (jqXHR.responseJSON && jqXHR.responseJSON.message) { |
|
504 | msg += ajax_error_msg(jqXHR); | |
496 | msg += jqXHR.responseJSON.message; |
|
|||
497 | } else { |
|
|||
498 | msg += jqXHR.statusText; |
|
|||
499 | } |
|
|||
500 | console.log(msg); |
|
505 | console.log(msg); | |
501 | }; |
|
506 | }; | |
502 |
|
507 | |||
@@ -519,6 +524,7 b' IPython.utils = (function (IPython) {' | |||||
519 | platform: platform, |
|
524 | platform: platform, | |
520 | is_or_has : is_or_has, |
|
525 | is_or_has : is_or_has, | |
521 | is_focused : is_focused, |
|
526 | is_focused : is_focused, | |
|
527 | ajax_error_msg : ajax_error_msg, | |||
522 | log_ajax_error : log_ajax_error, |
|
528 | log_ajax_error : log_ajax_error, | |
523 | }; |
|
529 | }; | |
524 |
|
530 |
@@ -2125,13 +2125,14 b' var IPython = (function (IPython) {' | |||||
2125 | */ |
|
2125 | */ | |
2126 | Notebook.prototype.load_notebook_error = function (xhr, status, error) { |
|
2126 | Notebook.prototype.load_notebook_error = function (xhr, status, error) { | |
2127 | $([IPython.events]).trigger('notebook_load_failed.Notebook', [xhr, status, error]); |
|
2127 | $([IPython.events]).trigger('notebook_load_failed.Notebook', [xhr, status, error]); | |
2128 | var msg; |
|
2128 | utils.log_ajax_error(xhr, status, error); | |
|
2129 | var msg = $("<div>"); | |||
2129 | if (xhr.status === 400) { |
|
2130 | if (xhr.status === 400) { | |
2130 | msg = error; |
|
2131 | msg.text(utils.ajax_error_msg(xhr)); | |
2131 | } else if (xhr.status === 500) { |
|
2132 | } else if (xhr.status === 500) { | |
2132 |
msg |
|
2133 | msg.text("An unknown error occurred while loading this notebook. " + | |
2133 | "This version can load notebook formats " + |
|
2134 | "This version can load notebook formats " + | |
2134 | "v" + this.nbformat + " or earlier."; |
|
2135 | "v" + this.nbformat + " or earlier. See the server log for details."); | |
2135 | } |
|
2136 | } | |
2136 | IPython.dialog.modal({ |
|
2137 | IPython.dialog.modal({ | |
2137 | title: "Error loading notebook", |
|
2138 | title: "Error loading notebook", | |
@@ -2402,10 +2403,10 b' var IPython = (function (IPython) {' | |||||
2402 | * @method delete_checkpoint_error |
|
2403 | * @method delete_checkpoint_error | |
2403 | * @param {jqXHR} xhr jQuery Ajax object |
|
2404 | * @param {jqXHR} xhr jQuery Ajax object | |
2404 | * @param {String} status Description of response status |
|
2405 | * @param {String} status Description of response status | |
2405 |
* @param {String} error |
|
2406 | * @param {String} error HTTP error message | |
2406 | */ |
|
2407 | */ | |
2407 |
Notebook.prototype.delete_checkpoint_error = function (xhr, status, error |
|
2408 | Notebook.prototype.delete_checkpoint_error = function (xhr, status, error) { | |
2408 | $([IPython.events]).trigger('checkpoint_delete_failed.Notebook'); |
|
2409 | $([IPython.events]).trigger('checkpoint_delete_failed.Notebook', [xhr, status, error]); | |
2409 | }; |
|
2410 | }; | |
2410 |
|
2411 | |||
2411 |
|
2412 |
@@ -80,6 +80,8 b' 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