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

Commitd7ab7ec

Browse files
iSnowGoodforGod
authored andcommitted
Added better handling of communication errors
(cherry picked from commit2893283)
1 parent1e03995 commitd7ab7ec

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

‎src/main/java/io/api/etherscan/error/ConnectionException.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
*/
99
publicclassConnectionExceptionextendsApiException {
1010

11+
publicConnectionException(Stringmessage) {
12+
super(message);
13+
}
14+
1115
publicConnectionException(Stringmessage,Throwablecause) {
1216
super(message,cause);
1317
}

‎src/main/java/io/api/etherscan/executor/impl/HttpExecutor.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
importjava.util.zip.GZIPInputStream;
1919
importjava.util.zip.InflaterInputStream;
2020

21-
importstaticjava.net.HttpURLConnection.HTTP_MOVED_PERM;
22-
importstaticjava.net.HttpURLConnection.HTTP_MOVED_TEMP;
21+
importstaticjava.net.HttpURLConnection.*;
2322

2423
/**
2524
* Http client implementation
@@ -88,6 +87,10 @@ public String get(final String urlAsString) {
8887
finalintstatus =connection.getResponseCode();
8988
if (status ==HTTP_MOVED_TEMP ||status ==HTTP_MOVED_PERM) {
9089
returnget(connection.getHeaderField("Location"));
90+
}elseif ((status >=HTTP_BAD_REQUEST) && (status <HTTP_INTERNAL_ERROR)) {
91+
thrownewConnectionException("Protocol error: "+connection.getResponseMessage());
92+
}elseif (status >=HTTP_INTERNAL_ERROR) {
93+
thrownewConnectionException("Server error: "+connection.getResponseMessage());
9194
}
9295

9396
finalStringdata =readData(connection);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp