@staticmethod
def _check_resource_failure(value, user_fail_string=None,
    global_fail_string=None, user_max=None, global_max=None, global_min=
    None, pretty_print=lambda x: str(x)):
    """
        Returns a failure message in case a certain resource limit is not respected.
        If value > user_max, user_fail_string is formatted with value and user_max in that order
        If value > global_max, global_fail_string is formatted with value and global_max in that order
        If value < global_min, global_fail_string is formatted with value and global_min in that order
        Pretty print is applied to both the value and max values before they're passed on to the functions
        The strings should expect string inputs for formatting and pretty_print should convert values to strings
        """
    if value:
        if user_max and value > user_max:
            return user_fail_string % (pretty_print(value), pretty_print(
                user_max), pretty_print(value - user_max))
        elif global_max and value > global_max:
            return global_fail_string % (pretty_print(value), pretty_print(
                global_max), pretty_print(value - global_max))
        elif global_min and value < global_min:
            return global_fail_string % (pretty_print(value), pretty_print(
                global_min), pretty_print(global_min - value))
    return None
