<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def api(f):
 """Decorator for functions and methods that are part of the external module API and that can throw XPathError exceptions. The call stack for these exceptions can be very large, and not very interesting to the user. This decorator rethrows XPathErrors to trim the stack. """

    def api_function(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        except XPathError, e:
            raise e
    api_function.__name__ = f.__name__
    api_function.__doc__ = f.__doc__
    return api_function