'Action upon error
@param status: HTTP status code
@param message: the error message
@param tree: the tree causing the error'

def error(self, status, message, tree=None, next=None):

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