better message when notebook format is not supported

Different messages for bad version and bad JSON.

closes #1592
This commit is contained in:
MinRK 2013-07-23 12:35:50 -07:00
parent 6fd10471e1
commit 2a09958bb6
2 changed files with 16 additions and 15 deletions

View File

@ -146,8 +146,9 @@ class FileNotebookManager(NotebookManager):
try: try:
# v1 and v2 and json in the .ipynb files. # v1 and v2 and json in the .ipynb files.
nb = current.reads(s, u'json') nb = current.reads(s, u'json')
except Exception as e: except ValueError as e:
raise web.HTTPError(500, u'Unreadable JSON notebook: %s' % e) msg = u"Unreadable Notebook: %s" % e
raise web.HTTPError(400, msg, reason=msg)
return last_modified, nb return last_modified, nb
def read_notebook_object(self, notebook_id): def read_notebook_object(self, notebook_id):

View File

@ -1794,20 +1794,20 @@ var IPython = (function (IPython) {
* @param {String} errorThrow HTTP error message * @param {String} errorThrow HTTP error message
*/ */
Notebook.prototype.load_notebook_error = function (xhr, textStatus, errorThrow) { Notebook.prototype.load_notebook_error = function (xhr, textStatus, errorThrow) {
if (xhr.status === 500) { if (xhr.status === 400) {
var msg = "An error occurred while loading this notebook. Most likely " + var msg = errorThrow;
"this notebook is in a newer format than is supported by this " + } else if (xhr.status === 500) {
"version of IPython. This version can load notebook formats " + var msg = "An unknown error occurred while loading this notebook. " +
"v"+this.nbformat+" or earlier."; "This version can load notebook formats " +
"v" + this.nbformat + " or earlier.";
IPython.dialog.modal({
title: "Error loading notebook",
body : msg,
buttons : {
"OK": {}
}
});
} }
IPython.dialog.modal({
title: "Error loading notebook",
body : msg,
buttons : {
"OK": {}
}
});
} }
/********************* checkpoint-related *********************/ /********************* checkpoint-related *********************/