send an error to the client. text message is formatted in a json stream

def send_error_json(self, code, message, headers=None):
        "send an error to the client. text message is formatted in a json stream"
        if headers is None:
            headers = {}

        self.end_response(HttpResponseJson(code,
                                           {'code':    code,
                                            'message': message},
                                           headers))