Skip to content

Commit

Permalink
Merge pull request #17 from AlphaWallet/capture-429s
Browse files Browse the repository at this point in the history
Capture 429s for batched requests
  • Loading branch information
hboon authored Aug 18, 2022
2 parents d4836bd + 1f52ad6 commit 72d6514
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions web3swift/Promises/Classes/Promise+HttpProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ extension Web3HttpProvider {
// let debugString = String(data: requestData, encoding: .utf8)
// print(debugString)
task = session.dataTask(with: urlRequest){ (data, response, error) in
if let statusCode = (response as? HTTPURLResponse)?.statusCode, statusCode == 429 {
rp.resolver.reject(Web3Error.rateLimited)
return
}
guard error == nil else {
rp.resolver.reject(error!)
return
Expand Down

0 comments on commit 72d6514

Please sign in to comment.