'Returns the JSON representation of an error message'

def error(self, code, message=None):

    self.response.set_status(code)
    error = {'error': True, 'code': code}
    if message:
        error['message'] = message
    self.json(error)
