actions: Handle OSErrors when listing action configs.
[matthijs/projects/backupninja.git] / src / lib / backupninja / action.py
index bb54d0a168f8b6985505ca658903b0c705a60baa..66fc5f364830f5b5221db05e44eab691a6115534 100644 (file)
@@ -33,7 +33,12 @@ def run_all_actions(opts, global_config):
     opts are the parsed commandline options, global_config is the parsed
     global configuration.
     """
-    actions = config.list_actions(opts)
+    try:
+        actions = config.list_actions(opts)
+    except OSError, e:
+        log.critical('Unable to list actions: %s', e)
+        return
+
     actions.sort()
 
     for action in actions:
@@ -53,15 +58,12 @@ def run_action(action, opts, global_config):
 
     # Get the config for this action
     action_config = config.get_action_config(opts, action)
-    # Create a handler for this action
-    handler = handlers.create_handler(action_ty, action_config)
 
-    # 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)
+    try:
+        # Create a handler for this action
+        handler = handlers.create_handler(action_ty, action_config)
+        # Run it
+        handler.run()
+        handler.finish()
+    except Exception, e:
+        log.error('Running action "%s" failed: %s', action, e)