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:
# v1 and v2 and json in the .ipynb files.
nb = current.reads(s, u'json')
except Exception as e:
raise web.HTTPError(500, u'Unreadable JSON notebook: %s' % e)
except ValueError as e:
msg = u"Unreadable Notebook: %s" % e
raise web.HTTPError(400, msg, reason=msg)
return last_modified, nb
def read_notebook_object(self, notebook_id):

View File

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