def exception(exception):
def decorator(func):<EOL><INDENT>@wraps(func)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>try:<EOL><INDENT>return func(*args, **kwargs)<EOL><DEDENT>except Exception as exe:<EOL><INDENT>raise raise_with_traceback(exception(exe))<EOL><DEDENT><DEDENT>return wrapper<EOL><DEDENT>return decorator<EOL>
Wrap function/method with specific exception if any
exception occurs during function execution.

Args:
    exception (Exception): Exception to re-cast error as.

Examples:
    >>> from gems import exception
    >>>
    >>> class MyCustomException(Exception):
    >>>     pass
    >>>
    >>> @exception(MyCustomException)
    >>> def func():
    >>>     return 1 / 0
    >>>
    >>> func()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "gems/decorators.py", line 96, in wrapper
        return func(*args, **kwargs)
      File "<stdin>", line 3, in func
    __main__.MyCustomException: integer division or modulo by zero