def decorator_log_exception()

in cookbooks/aws-parallelcluster-computefleet/files/clusterstatusmgtd/clusterstatusmgtd.py [0:0]


    def decorator_log_exception(function):
        @functools.wraps(function)
        def wrapper_log_exception(*args, **kwargs):  # pylint: disable=R1710
            try:
                return function(*args, **kwargs)
            except catch_exception as e:
                logger.log(log_level, "Failed when %s with exception %s", action_desc, e)
                if raise_on_error:
                    if exception_to_raise:
                        raise exception_to_raise
                    raise
                return None

        return wrapper_log_exception