Skip to content

Commit

Permalink
Improved error reporting on comms
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Oct 5, 2016
1 parent 8e14bbb commit 63c1460
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions holoviews/plotting/comms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import json
import uuid
import sys
import os
import traceback

from ipykernel.comm import Comm as IPyComm
from IPython import get_ipython
Expand Down Expand Up @@ -70,10 +73,16 @@ def _handle_msg(self, msg):
if it has been defined.
"""
try:
msg = self.decode(msg)
if self._on_msg:
self._on_msg(self.decode(msg))
self._on_msg(msg)
except Exception as e:
msg = {'msg_type': "Error", 'traceback': str(e)}
frame =traceback.extract_tb(sys.exc_info()[2])[-2]
fname,lineno,fn,text = frame
error_kwargs = dict(type=type(e).__name__, fn=fn, fname=fname,
line=lineno, error=str(e))
error = '{fname} {fn} L{line}\n\t{type}: {error}'.format(**error_kwargs)
msg = {'msg_type': "Error", 'traceback': error}
else:
msg = {'msg_type': "Ready"}
self.comm.send(json.dumps(msg))
Expand Down

0 comments on commit 63c1460

Please sign in to comment.