MCPcopy Create free account
hub / github.com/ccxt/ccxt / handle_errors

Method handle_errors

python/ccxt/grvt.py:3131–3158  ·  view source on GitHub ↗
(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody)

Source from the content-addressed store, hash-verified

3129 return {'url': url, 'method': method, 'body': body, 'headers': headers}
3130
3131 def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
3132 if url.endswith('auth/api_key/login') or url.endswith('auth/wallet/login'):
3133 accountId = self.safe_string_2(headers, 'X-Grvt-Account-Id', 'x-grvt-account-id')
3134 self.options['AuthAccountId'] = accountId
3135 cookie = self.safe_string_2(headers, 'Set-Cookie', 'set-cookie')
3136 if cookie is not None:
3137 cookieValue = cookie.split(';')[0]
3138 self.options['AuthCookieValue'] = cookieValue
3139 if self.options['AuthCookieValue'] is None or self.options['AuthAccountId'] is None:
3140 raise AuthenticationError(self.id + ' signIn() failed to receive auth-cookie or account-id')
3141 else:
3142 errorCode = self.safe_string(response, 'code')
3143 if errorCode is not None:
3144 feedback = self.id + ' ' + body
3145 self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
3146 raise ExchangeError(feedback)
3147 else:
3148 message = self.safe_string(response, 'message')
3149 if message is not None:
3150 feedback = self.id + ' ' + body
3151 self.throw_broadly_matched_exception(self.exceptions['broad'], message, feedback)
3152 raise ExchangeError(feedback)
3153 else:
3154 status = self.safe_string(response, 'status')
3155 if status is not None and status != 'success':
3156 feedback = self.id + ' ' + body
3157 raise ExchangeError(feedback)
3158 return None

Callers

nothing calls this directly

Calls 7

AuthenticationErrorClass · 0.90
ExchangeErrorClass · 0.90
safe_string_2Method · 0.80
splitMethod · 0.80
safe_stringMethod · 0.80

Tested by

no test coverage detected