X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fprojects%2Fbackupninja.git;a=blobdiff_plain;f=src%2Flib%2Fbackupninja%2Fhandlers%2F__init__.py;fp=src%2Flib%2Fbackupninja%2Fhandlers%2F__init__.py;h=29dc75631823ed79d5ecda18b99698d6dcacb782;hp=dbc403e04585e21f167410da25d8da99f938bd06;hb=96f1913c89c0d934c9b75ff9fae2c0eda44e4823;hpb=83ac2051e6b8583650fa9ce295afe8c61526b692 diff --git a/src/lib/backupninja/handlers/__init__.py b/src/lib/backupninja/handlers/__init__.py index dbc403e..29dc756 100644 --- a/src/lib/backupninja/handlers/__init__.py +++ b/src/lib/backupninja/handlers/__init__.py @@ -24,6 +24,20 @@ import logging as log from backupninja import config +def fail_on_exception(f): + """ + This is a decorator meant for methods on the Action class. It + catches any exceptions thrown, sets the failed attribute to True and + rethrows the exception. + """ + def inner(self, *args, **kwargs): + try: + f(self, *args, **kwargs) + except: + self.failed = True + raise + return inner + class Action(object): """ Subclasses of Action represent handlers for various action types.