def catch_exceptions(func):
"""
Catches and simplifies expected errors thrown by sceptre.
catch_exceptions should be used as a decorator.
:param func: The function which may throw exceptions which should be
simplified.
:type func: func
:returns: The decorated function.
:rtype: func
"""
@wraps(func)
def decorated(*args, **kwargs):
"""
Invokes ``func``, catches expected errors, prints the error message and
exits sceptre with a non-zero exit code.
"""
try:
return func(*args, **kwargs)
except (SceptreException, BotoCoreError, ClientError, Boto3Error,
TemplateError) as error:
write(error)
sys.exit(1)
return decorated
评论列表
文章目录