Skip to content

Commit

Permalink
Merge pull request #35 from josh-richardson/fix-exception-stacktrace
Browse files Browse the repository at this point in the history
return something more sane if fund fails
  • Loading branch information
josh-richardson committed Feb 26, 2020
2 parents 123e5e3 + 72d248e commit 95eb84b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/main/java/org/web3j/console/WalletFunder.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,22 @@ public static String fundWallet(String walletAddress, Faucet faucet, String toke
.post(fundingBody)
.build();
}
try {
Response sendRawResponse = client.newCall(sendEtherRequest).execute();

Response sendRawResponse = client.newCall(sendEtherRequest).execute();

if (sendRawResponse.code() != 200) {
exitError(
String.format(
"\nAn HTTP request failed with code: %d", sendRawResponse.code()));
}

String sendResponse = sendRawResponse.body().string();
if (sendRawResponse.code() != 200) {
exitError(
String.format(
"\nAn HTTP request failed with code: %d", sendRawResponse.code()));
}

WalletFunderResult result = mapper.readValue(sendResponse, WalletFunderResult.class);
String sendResponse = sendRawResponse.body().string();

return result.result;
WalletFunderResult result = mapper.readValue(sendResponse, WalletFunderResult.class);
return result.result;
} catch (Exception ex) {
return "The fund operation failed - this may be due to an issue with the remote server. Please try again.";
}
}
}

Expand Down

0 comments on commit 95eb84b

Please sign in to comment.