def wrap_errors(errors=None, processor=None, *args):
def wrapper(func):<EOL><INDENT>if errors:<EOL><INDENT>setattr(func, ATTR_WRAPPED_EXCEPTIONS, errors)<EOL><DEDENT>if processor:<EOL><INDENT>setattr(func, ATTR_WRAPPED_EXCEPTIONS_PROCESSOR, processor)<EOL><DEDENT>return func<EOL><DEDENT>return wrapper<EOL>
Decorator. Wraps given exceptions into
:class:`~argh.exceptions.CommandError`. Usage::

    @wrap_errors([AssertionError])
    def foo(x=None, y=None):
        assert x or y, 'x or y must be specified'

If the assertion fails, its message will be correctly printed and the
stack hidden. This helps to avoid boilerplate code.

:param errors:
    A list of exception classes to catch.
:param processor:
    A callable that expects the exception object and returns a string.
    For example, this renders all wrapped errors in red colour::

        from termcolor import colored

        def failure(err):
            return colored(str(err), 'red')

        @wrap_errors(processor=failure)
        def my_command(...):
            ...