File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
src/main/java/io/api/etherscan Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 88 */
99public class ConnectionException extends ApiException {
1010
11+ public ConnectionException (String message ) {
12+ super (message );
13+ }
14+
1115 public ConnectionException (String message , Throwable cause ) {
1216 super (message , cause );
1317 }
Original file line number Diff line number Diff line change 1818import java .util .zip .GZIPInputStream ;
1919import java .util .zip .InflaterInputStream ;
2020
21- import static java .net .HttpURLConnection .HTTP_MOVED_PERM ;
22- import static java .net .HttpURLConnection .HTTP_MOVED_TEMP ;
21+ import static java .net .HttpURLConnection .*;
2322
2423/**
2524 * Http client implementation
@@ -88,6 +87,10 @@ public String get(final String urlAsString) {
8887 final int status = connection .getResponseCode ();
8988 if (status == HTTP_MOVED_TEMP || status == HTTP_MOVED_PERM ) {
9089 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 ());
9194 }
9295
9396 final String data = readData (connection );
You can’t perform that action at this time.
0 commit comments