File tree 2 files changed +9
-2
lines changed
src/main/java/io/api/etherscan
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 8
8
*/
9
9
public class ConnectionException extends ApiException {
10
10
11
+ public ConnectionException (String message ) {
12
+ super (message );
13
+ }
14
+
11
15
public ConnectionException (String message , Throwable cause ) {
12
16
super (message , cause );
13
17
}
Original file line number Diff line number Diff line change 18
18
import java .util .zip .GZIPInputStream ;
19
19
import java .util .zip .InflaterInputStream ;
20
20
21
- import static java .net .HttpURLConnection .HTTP_MOVED_PERM ;
22
- import static java .net .HttpURLConnection .HTTP_MOVED_TEMP ;
21
+ import static java .net .HttpURLConnection .*;
23
22
24
23
/**
25
24
* Http client implementation
@@ -88,6 +87,10 @@ public String get(final String urlAsString) {
88
87
final int status = connection .getResponseCode ();
89
88
if (status == HTTP_MOVED_TEMP || status == HTTP_MOVED_PERM ) {
90
89
return get (connection .getHeaderField ("Location" ));
90
+ } else if ((status >= HTTP_BAD_REQUEST ) && (status < HTTP_INTERNAL_ERROR )) {
91
+ throw new ConnectionException ("Protocol error: " +connection .getResponseMessage ());
92
+ } else if (status >= HTTP_INTERNAL_ERROR ) {
93
+ throw new ConnectionException ("Server error: " +connection .getResponseMessage ());
91
94
}
92
95
93
96
final String data = readData (connection );
You can’t perform that action at this time.
0 commit comments