'Action upon error
@param status: HTTP status code
@param message: the error message
@param _next: destination URL for redirection upon error
(defaults to the index page of the module)'

def error(self, status, message, _next=None):

    if (self.representation == 'html'):
        current.session.error = message
        if (_next is None):
            _next = URL(f='index')
        redirect(_next)
    else:
        current.log.error(message)
        if (self.representation == 'popup'):
            headers = {}
            body = DIV(message, _style='color:red')
        else:
            headers = {'Content-Type': 'application/json'}
            body = current.xml.json_message(success=False, statuscode=status, message=message)
        raise HTTP(status, body=body, web2py_error=message, **headers)
