@@ -0,0 +1,1808 @@
+from app import error_email%0Afrom app.models import db%0Aimport botocore%0Aimport logging%0Aimport traceback%0A%0Adef _client_error_exception(exception, key):%0A    def _accessdenied_ce_exception():%0A        error_email.aws_access_denied_error_email(key, traceback.format_exc())%0A        key.error_status = u%22access_denied%22%0A        logging.error(%22%5Buser=%7B%7D%5D%5Bkey=%7B%7D%5D Insufficient access rights%22.format(key.user.email, key.pretty or key.key))%0A%0A    def _nosuchbucket_ce_exception():%0A        error_email.aws_bucket_does_not_exist_error_email(key, traceback.format_exc())%0A        key.error_status = u%22no_such_bucket%22%0A        logging.error(%22%5Buser=%7B%7D%5D%5Bkey=%7B%7D%5D The specified billing bucket does not exists%22.format(key.user.email, key.pretty or key.key))%0A%0A    def _default_ce_exception():%0A        error_email.aws_credentials_error(key, traceback.format_exc())%0A        key.error_status = u%22bad_key%22%0A        logging.error(%22%5Buser=%7B%7D%5D%5Bkey=%7B%7D%5D %7B%7D%22.format(key.user.email, key.pretty or key.key, str(exception)))%0A    %0A    _code_handler = %7B%0A        'AccessDenied': _accessdenied_ce_exception,%0A        'NoSuchBucket': _nosuchbucket_ce_exception,%0A    %7D%0A    _code_handler.get(exception.response%5B'Error'%5D%5B'Code'%5D, _default_ce_exception)()%0A    db.session.commit()%0A%0Adef _default_exception(exception, key):%0A    error_email.aws_key_processing_generic_error_email(key, traceback.format_exc())%0A    key.error_status = u%22processing_error%22%0A    db.session.commit()%0A    #logging.error(%22%5Buser=%7B%7D%5D%5Bkey=%7B%7D%5D %7B%7D%22.format(key.user.email, key.pretty or key.key, str(e)))%0A%0AEXCEPTION_HANDLERS = %7B%0A    botocore.exceptions.ClientError: _client_error_exception,%0A%7D%0A%0Adef except_handler(exception, key):%0A    for e, f in EXCEPTION_HANDLERS.iteritems():%0A        if isinstance(exception, e):%0A            return f(exception, key)%0A    return _default_exception(exception, key)%0A

Add the except handler