diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js index b8aba88..6b731c1 100644 --- a/IPython/html/static/base/js/utils.js +++ b/IPython/html/static/base/js/utils.js @@ -488,15 +488,20 @@ IPython.utils = (function (IPython) { } } + var ajax_error_msg = function (jqXHR) { + // Return a JSON error message if there is one, + // otherwise the basic HTTP status text. + if (jqXHR.responseJSON && jqXHR.responseJSON.message) { + return jqXHR.responseJSON.message; + } else { + return jqXHR.statusText; + } + } var log_ajax_error = function (jqXHR, status, error) { // log ajax failures with informative messages var msg = "API request failed (" + jqXHR.status + "): "; console.log(jqXHR); - if (jqXHR.responseJSON && jqXHR.responseJSON.message) { - msg += jqXHR.responseJSON.message; - } else { - msg += jqXHR.statusText; - } + msg += ajax_error_msg(jqXHR); console.log(msg); }; @@ -519,6 +524,7 @@ IPython.utils = (function (IPython) { platform: platform, is_or_has : is_or_has, is_focused : is_focused, + ajax_error_msg : ajax_error_msg, log_ajax_error : log_ajax_error, }; diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 7eb913e..1fdb103 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -2125,13 +2125,14 @@ var IPython = (function (IPython) { */ Notebook.prototype.load_notebook_error = function (xhr, status, error) { $([IPython.events]).trigger('notebook_load_failed.Notebook', [xhr, status, error]); - var msg; + utils.log_ajax_error(xhr, status, error); + var msg = $("