From 32a969c6e2e4960765e2579d17f39cf58400a44f 2013-12-23 01:46:53 From: MinRK Date: 2013-12-23 01:46:53 Subject: [PATCH] catch pandoc failures in nbconvert handlers --- diff --git a/IPython/html/nbconvert/handlers.py b/IPython/html/nbconvert/handlers.py index b7197a7..9a65a02 100644 --- a/IPython/html/nbconvert/handlers.py +++ b/IPython/html/nbconvert/handlers.py @@ -62,8 +62,11 @@ class NbconvertFileHandler(IPythonHandler): info = os.stat(os_path) self.set_header('Last-Modified', tz.utcfromtimestamp(info.st_mtime)) - - output, resources = exporter.from_filename(os_path) + + try: + output, resources = exporter.from_filename(os_path) + except Exception as e: + raise web.HTTPError(500, "nbconvert failed: %s" % e) if respond_zip(self, name, output, resources): return @@ -90,8 +93,11 @@ class NbconvertPostHandler(IPythonHandler): model = self.get_json_body() nbnode = to_notebook_json(model['content']) - - output, resources = exporter.from_notebook_node(nbnode) + + try: + output, resources = exporter.from_notebook_node(nbnode) + except Exception as e: + raise web.HTTPError(500, "nbconvert failed: %s" % e) if respond_zip(self, nbnode.metadata.name, output, resources): return