'The @app.error(code) decorator defines the handler function for the given HTTP error.
The function takes a HTTPError object and returns a string.'

def error(self, code='*'):

    def decorator(handler):
        def wrapper(status='', message='', traceback='', version=''):
            v = handler(HTTPError(status, message, traceback))
            v = (self._cast(v) if (not isinstance(v, HTTPError)) else repr(v))
            return v
        if (code in ('*', None)):
            cp.config.update({'error_page.default': wrapper})
        elif isinstance(code, (int, basestring)):
            cp.config.update({('error_page.%s' % code): wrapper})
        elif isinstance(code, (tuple, list)):
            for x in code:
                cp.config.update({('error_page.%s' % x): wrapper})
        return handler
    return decorator
