def __init__(self, data=None): if data is None: data = self.default_msg data = json.dumps(data) Response.__init__(self, text=data, status=self.status, content_type='application/json') Exception.__init__(self)
def __init__(self, body=irc['INTERNAL_SERVER_ERROR'], status=500): Response.__init__( self, status=status, headers=None, reason=None, text=None, content_type='application/json', body=json.dumps({"errors": body}), )
def __init__(self, msg=None, *, headers=None, reason=None, body=None, text=None, content_type='application/json'): Response.__init__(self, status=self.status_code, headers=headers, reason=reason, body=body, text=text, content_type=content_type) Exception.__init__(self, self.reason) if msg: self.text = json.dumps({'message': msg}) elif self.body is None and not self.empty_body: self.text = json.dumps({'message': self.reason})