Skip to content

Commit

Permalink
Capture rate limited errors (429s) for batch requests
Browse files Browse the repository at this point in the history
  • Loading branch information
hboon committed Aug 18, 2022
1 parent d4836bd commit 1f52ad6
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 1f52ad6

Please sign in to comment.