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

Method handle_errors

python/ccxt/hyperliquid.py:4490–4532  ·  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

4488 return self.safe_currency_code(coin) + '/USDC:USDC'
4489
4490 def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
4491 if not response:
4492 return None # fallback to default error handler
4493 # {"status":"err","response":"User or API Wallet 0xb8a6f8b26223de27c31938d56e470a5b832703a5 does not exist."}
4494 #
4495 # {
4496 # status: 'ok',
4497 # response: {type: 'order', data: {statuses: [{error: 'Insufficient margin to place order. asset=4'}]}}
4498 # }
4499 # {"status":"ok","response":{"type":"order","data":{"statuses":[{"error":"Insufficient margin to place order. asset=84"}]}}}
4500 #
4501 # {"status":"unknownOid"}
4502 #
4503 status = self.safe_string(response, 'status', '')
4504 error = self.safe_string(response, 'error')
4505 message = None
4506 if status == 'err':
4507 message = self.safe_string(response, 'response')
4508 elif status == 'unknownOid':
4509 raise OrderNotFound(self.id + ' ' + body) # {"status":"unknownOid"}
4510 elif error is not None:
4511 message = error
4512 else:
4513 responsePayload = self.safe_dict(response, 'response', {})
4514 data = self.safe_dict(responsePayload, 'data', {})
4515 statuses = self.safe_list(data, 'statuses', [])
4516 for i in range(0, len(statuses)):
4517 message = self.safe_string(statuses[i], 'error')
4518 if message is not None:
4519 break
4520 if 'status' in data:
4521 errorStatus = self.safe_dict(data, 'status', {})
4522 errorMsg = self.safe_string(errorStatus, 'error')
4523 if errorStatus is not None:
4524 message = errorMsg
4525 feedback = self.id + ' ' + body
4526 nonEmptyMessage = ((message is not None) and (message != ''))
4527 if nonEmptyMessage:
4528 self.throw_exactly_matched_exception(self.exceptions['exact'], message, feedback)
4529 self.throw_broadly_matched_exception(self.exceptions['broad'], message, feedback)
4530 if nonEmptyMessage:
4531 raise ExchangeError(feedback) # unknown message
4532 return None
4533
4534 def sign(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None):
4535 url = self.implode_hostname(self.urls['api'][api]) + '/' + path

Callers

nothing calls this directly

Calls 8

OrderNotFoundClass · 0.90
ExchangeErrorClass · 0.90
safe_stringMethod · 0.80
safe_dictMethod · 0.80
safe_listMethod · 0.80
rangeFunction · 0.50

Tested by

no test coverage detected