def log_exceptions(logger):
 def decorator(func):
  @wraps(func)
  def wrapper(*args, **kwargs):
   try:
    result = func(*args, **kwargs)
   except Exception:
    logger.exception(u'Uncaught exception while running {0}'.format(func.__name__))
    raise
   return result
  return wrapper
 return decorator

def log_exceptions ( logger ) : def decorator ( func ) : @ wraps ( func ) def wrapper ( * args , ** kwargs ) : try : result = func ( * args , ** kwargs ) except Exception : logger . exception ( u'Uncaught exception while running {0}' . format ( func . __name__ ) ) raise return result return wrapper return decorator
a decorator that catches any exceptions thrown by the decorated function and logs them along with a traceback .