def wrap_exception(notifier=None, get_notifier=None, binary=None):
 def inner(f):
  def wrapped(self, context, *args, **kw):
   try:
    return f(self, context, *args, **kw)
   except Exception as e:
    with excutils.save_and_reraise_exception():
     if (notifier or get_notifier):
      call_dict = _get_call_dict(f, self, context, *args, **kw)
      function_name = f.__name__
      _emit_exception_notification((notifier or get_notifier()), context, e, function_name, call_dict, binary)
  return functools.wraps(f)(wrapped)
 return inner

def wrap_exception ( notifier = None , get_notifier = None , binary = None ) : def inner ( f ) : def wrapped ( self , context , * args , ** kw ) : try : return f ( self , context , * args , ** kw ) except Exception as e : with excutils . save_and_reraise_exception ( ) : if ( notifier or get_notifier ) : call_dict = _get_call_dict ( f , self , context , * args , ** kw ) function_name = f . __name__ _emit_exception_notification ( ( notifier or get_notifier ( ) ) , context , e , function_name , call_dict , binary ) return functools . wraps ( f ) ( wrapped ) return inner
this decorator wraps a method to catch any exceptions that may get thrown .