Example #1
0
 def __init__(self, **kwargs):
     try:
         super(VNFMgrException, self).__init__(self.message % kwargs)
         self.msg = self.message % kwargs
     except Exception:
         with excutils.save_and_reraise_exception() as ctxt:
             if not self.use_fatal_exceptions():
                 ctxt.reraise = False
                 # at least get the core message out if something happened
                 super(VNFMgrException, self).__init__(self.message)
Example #2
0
 def __init__(self, **kwargs):
     try:
         super(VNFMgrException, self).__init__(self.message % kwargs)
         self.msg = self.message % kwargs
     except Exception:
         with excutils.save_and_reraise_exception() as ctxt:
             if not self.use_fatal_exceptions():
                 ctxt.reraise = False
                 # at least get the core message out if something happened
                 super(VNFMgrException, self).__init__(self.message)
Example #3
0
def remove_path_on_error(path, remove=delete_if_exists):
    """Protect code that wants to operate on PATH atomically.
    Any exception will cause PATH to be removed.

    :param path: File to work with
    :param remove: Optional function to remove passed path
    """

    try:
        yield
    except Exception:
        with excutils.save_and_reraise_exception():
            remove(path)
Example #4
0
 def call(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except Exception as e:
         with excutils.save_and_reraise_exception():
             self.logger(e)
Example #5
0
 def call(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except Exception as e:
         with excutils.save_and_reraise_exception():
             self.logger(e)