Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita4e4b09

Browse files
iSnowGoodforGod
authored andcommitted
Added support for rate limiting by Etherscan: throw RateLimitException
(cherry picked from commit120ba0f)
1 parent5729da7 commita4e4b09

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

‎src/main/java/io/api/etherscan/core/impl/BasicProvider.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
packageio.api.etherscan.core.impl;
22

33
importcom.google.gson.Gson;
4+
importcom.google.gson.JsonSyntaxException;
45
importio.api.etherscan.error.EtherScanException;
56
importio.api.etherscan.error.ParseException;
7+
importio.api.etherscan.error.RateLimitException;
68
importio.api.etherscan.executor.IHttpExecutor;
79
importio.api.etherscan.manager.IQueueManager;
810
importio.api.etherscan.util.BasicUtils;
911

12+
importjava.util.Map;
13+
1014
/**
1115
* Base provider for API Implementations
1216
*
@@ -42,6 +46,19 @@ <T> T convert(final String json, final Class<T> tClass) {
4246
try {
4347
returngson.fromJson(json,tClass);
4448
}catch (Exceptione) {
49+
if (einstanceofJsonSyntaxException) {
50+
Map<String,Object>map =gson.fromJson(json,Map.class);
51+
ObjectstatusCode =map.get("status");
52+
if ((statusCodeinstanceofString) && (statusCode.equals("0"))) {
53+
Objectmessage =map.get("message");
54+
if ((messageinstanceofString) && (message.equals("NOTOK"))) {
55+
Objectresult =map.get("result");
56+
if ((resultinstanceofString) && (result.equals("Max rate limit reached"))) {
57+
thrownewRateLimitException ("Max rate limit reached");
58+
}
59+
}
60+
}
61+
}
4562
thrownewParseException(e.getMessage(),e.getCause(),json);
4663
}
4764
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
packageio.api.etherscan.error;
2+
3+
/**
4+
* ! NO DESCRIPTION !
5+
*
6+
* @author iSnow
7+
* @since 2020-10-06
8+
*/
9+
publicclassRateLimitExceptionextendsApiException {
10+
11+
publicRateLimitException(Stringmessage) {
12+
super(message);
13+
}
14+
15+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp