From: Matthijs Kooijman Date: Thu, 10 Jun 2010 06:18:29 +0000 (+0200) Subject: actions: Catch and log exceptions when running handlers. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fprojects%2Fbackupninja.git;a=commitdiff_plain;h=b28c821a628aa44d082d167c4527d7776af5699e actions: Catch and log exceptions when running handlers. --- diff --git a/src/lib/backupninja/action.py b/src/lib/backupninja/action.py index 3f57a18..95c43fd 100644 --- a/src/lib/backupninja/action.py +++ b/src/lib/backupninja/action.py @@ -21,6 +21,8 @@ """ Running backup actions """ +import logging as log + 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) - if handler: - # Run the handler - handler.run() - handler.finish() # 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)