import functools


def assert_on_error(func):
    """Raises assertion error exceptions if the wrapped method returned any errors."""
    @functools.wraps(func)
    def wrapped(*args, **kwargs):
        """Wrapped method."""
        value, errors = func(*args, **kwargs)
        if errors:
            raise AssertionError('\n\t' + '\n\t'.join(sorted(errors)))
        return value

    return wrapped