actions: Catch and log exceptions when running handlers.
authorMatthijs Kooijman <matthijs@stdin.nl>
Thu, 10 Jun 2010 06:18:29 +0000 (08:18 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Thu, 10 Jun 2010 06:18:29 +0000 (08:18 +0200)
src/lib/backupninja/action.py

index 3f57a188f7b9b6a2f171bbb7f4a34442110b2a6b..95c43fd9d940760f0ea990e6dacb6bdb07a6444e 100644 (file)
@@ -21,6 +21,8 @@
 
 """ Running backup actions """
 
 
 """ Running backup actions """
 
+import logging as log
+
 from backupninja import config
 from backupninja import handlers
 
 from backupninja import config
 from backupninja import handlers
 
@@ -53,9 +55,12 @@ def run_action(action, opts, global_config):
     # Create a handler for this action
     handler = handlers.create_handler(action_ty, action_config)
 
     # Create a handler for this action
     handler = handlers.create_handler(action_ty, action_config)
 
-    if handler:
-        # Run the handler
-        handler.run()
-        handler.finish()
     # Silently skip invalid handlers, create_handler will have
     # logged an error
     # Silently skip invalid handlers, create_handler will have
     # logged an error
+    if handler:
+        try:
+            # Run the handler
+            handler.run()
+            handler.finish()
+        except Exception, e:
+            log.error('Running action "%s" failed: %s', action, e)