def _log_exception()

in src/slurm_plugin/common.py [0:0]


    def _log_exception(function):
        @functools.wraps(function)
        def wrapper(*args, **kwargs):
            wrapped = None
            try:
                wrapped = function(*args, **kwargs)
            except catch_exception as e:
                logger.log(log_level, "Failed when %s with exception %s, message: %s", action_desc, type(e).__name__, e)
                if raise_on_error:
                    if exception_to_raise:
                        # preserve exception message if exception to raise is same of actual exception
                        raise e if isinstance(e, exception_to_raise) else exception_to_raise
                    else:
                        raise

            return wrapped

        return wrapper