def __init__(self, text, code=None):
if code is not None:
self.code = code
self.text = text
self.xml = None
# TODO(dcramer): pull in XML support from Jira
if text:
try:
self.json = json.loads(text, object_pairs_hook=OrderedDict)
except (JSONDecodeError, ValueError):
if self.text[:5] == "<?xml":
# perhaps it's XML?
self.xml = BeautifulStoneSoup(self.text)
# must be an awful code.
self.json = None
else:
self.json = None
super(ApiError, self).__init__(text[:128])
评论列表
文章目录