Improved exception handling in Callable
@@ -486,6 +486,7 @@ class Callable(param.Parameterized):
def __call__(self, *args, **kwargs):
# Nothing to do for callbacks that accept no arguments
+ (inargs, inkwargs) = (args, kwargs)
if not args and not kwargs: return self.callable()
inputs = [i for i in self.inputs if isinstance(i, DynamicMap)]
streams = []
@@ -515,8 +516,19 @@ class Callable(param.Parameterized):
% list(clashes))
args, kwargs = (), dict(pos_kwargs, **kwargs)
-
+ try:
ret = self.callable(*args, **kwargs)
+ except:
+ posstr = ', '.join(['%r' % el for el in inargs]) if inargs else ''
+ kwstr = ', '.join('%s=%r' % (k,v) for k,v in inkwargs.items())
+ argstr = ', '.join([el for el in [posstr, kwstr] if el])
+ message = ("Exception raised in callable '{name}' of type '{ctype}'.\n"
+ "Invoked as {name}({argstr})")
+ self.warning(message.format(name=util.callable_name(self.callable),
+ ctype = type(self.callable).__name__,
+ argstr=argstr))
+ raise
+
if hashed_key is not None:
self._memoized = {hashed_key : ret}
return ret
