orbs-network / ton-access

Unthrottled anonymous RPC access to TON blockchain via a robust decentralized network
MIT License
71 stars 4 forks source link

`getHttpEndpoint`: Improve error message on 429 error #46

Open jubnzv opened 5 days ago

jubnzv commented 5 days ago

When the IP address in use reaches the API limit for the endpoints utilized by getHttpEndpoint, the following error occurs:

Cannot initialize client: Error: exception in fetch(https://ton.access.orbs.network/mngr/nodes?npm_version=2.3.3): SyntaxError: Unexpected token '<', "
<?xml vers"... is not valid JSON
    at Nodes.<anonymous> (node_modules/@orbs-network/ton-access/src/nodes.ts:54:13)
    at Generator.throw (<anonymous>)
    at rejected (node_modules/@orbs-network/ton-access/lib/nodes.js:6:65)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)

Expected: A clear error message indicating that the user has reached the API limit and needs to wait for some time.