##// END OF EJS Templates
Merge pull request #5067 from minrk/widget-error...
Brian E. Granger -
r15213:2182b3fe merge
parent child Browse files
Show More
@@ -20,6 +20,7 b' except ImportError:'
20 20 from IPython.utils.signatures import signature, Parameter
21 21 from inspect import getcallargs
22 22
23 from IPython.core.getipython import get_ipython
23 24 from IPython.html.widgets import (Widget, TextWidget,
24 25 FloatSliderWidget, IntSliderWidget, CheckboxWidget, DropdownWidget,
25 26 ContainerWidget, DOMWidget)
@@ -205,7 +206,14 b' def interactive(__interact_f, **kwargs):'
205 206 container.kwargs[widget.description] = value
206 207 if co:
207 208 clear_output(wait=True)
208 container.result = f(**container.kwargs)
209 try:
210 container.result = f(**container.kwargs)
211 except Exception as e:
212 ip = get_ipython()
213 if ip is None:
214 container.log.warn("Exception in interact callback: %s", e, exc_info=True)
215 else:
216 ip.showtraceback()
209 217
210 218 # Wire up the widgets
211 219 for widget in kwargs_widgets:
@@ -14,6 +14,7 b' in the IPython notebook front-end.'
14 14 #-----------------------------------------------------------------------------
15 15 from contextlib import contextmanager
16 16
17 from IPython.core.getipython import get_ipython
17 18 from IPython.kernel.comm import Comm
18 19 from IPython.config import LoggingConfigurable
19 20 from IPython.utils.traitlets import Unicode, Dict, Instance, Bool, List, Tuple
@@ -33,7 +34,11 b' class CallbackDispatcher(LoggingConfigurable):'
33 34 try:
34 35 local_value = callback(*args, **kwargs)
35 36 except Exception as e:
36 self.log.warn("Exception in callback %s: %s", callback, e)
37 ip = get_ipython()
38 if ip is None:
39 self.log.warn("Exception in callback %s: %s", callback, e, exc_info=True)
40 else:
41 ip.showtraceback()
37 42 else:
38 43 value = local_value if local_value is not None else value
39 44 return value
@@ -54,6 +59,18 b' class CallbackDispatcher(LoggingConfigurable):'
54 59 elif not remove and callback not in self.callbacks:
55 60 self.callbacks.append(callback)
56 61
62 def _show_traceback(method):
63 """decorator for showing tracebacks in IPython"""
64 def m(self, *args, **kwargs):
65 try:
66 return(method(self, *args, **kwargs))
67 except Exception as e:
68 ip = get_ipython()
69 if ip is None:
70 self.log.warn("Exception in widget method %s: %s", method, e, exc_info=True)
71 else:
72 ip.showtraceback()
73 return m
57 74
58 75 class Widget(LoggingConfigurable):
59 76 #-------------------------------------------------------------------------
@@ -241,6 +258,7 b' class Widget(LoggingConfigurable):'
241 258 value != self._property_lock[1]
242 259
243 260 # Event handlers
261 @_show_traceback
244 262 def _handle_msg(self, msg):
245 263 """Called when a msg is received from the front-end"""
246 264 data = msg['content']['data']
General Comments 0
You need to be logged in to leave comments. Login now