Path: blob/master/bitget-python-sdk-api/bitget/exceptions.py
732 views
# coding=utf-81import json23class BitgetAPIException(Exception):45def __init__(self, response):6self.code = 07try:8json_res = response.json()9except ValueError:10self.message = 'Invalid JSON error message from Bitget: {}'.format(response.text)11else:12if "code" in json_res.keys() and "msg" in json_res.keys():13self.code = json_res['code']14self.message = json_res['msg']15else:16self.code = 'Please wait a moment'17self.message = 'Maybe something is wrong'1819self.status_code = response.status_code20self.response = response21self.request = getattr(response, 'request', None)2223def __str__(self): # pragma: no cover24return 'API Request Error(code=%s): %s' % (self.code, self.message)25262728class BitgetRequestException(Exception):2930def __init__(self, message):31self.message = message3233def __str__(self):34return 'BitgetRequestException: %s' % self.message35363738class BitgetParamsException(Exception):3940def __init__(self, message):41self.message = message4243def __str__(self):44return 'BitgetParamsException: %s' % self.message454647