diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java index 2553ae7..7e0f047 100644 --- a/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java @@ -13,6 +13,8 @@ import org.springframework.web.client.RestTemplate; import djmil.cordacheckers.cordaclient.dao.VirtualNode; import djmil.cordacheckers.cordaclient.dao.VirtualNodeList; +import static java.util.Objects.requireNonNull; + @Service public class CordaClient { private final RestTemplate restTemplate; @@ -39,12 +41,12 @@ public class CordaClient { request, VirtualNodeList.class ); - // TODO: throw exeption instead - if (resp.getStatusCode() != HttpStatus.OK || !resp.hasBody()) { - return null; + if (resp.getStatusCode() != HttpStatus.OK) { + throw new RuntimeException("CordaClient.getVirtualNodeList: unexpected request status "+resp.getStatusCode()) ; } - return resp.getBody().virtualNodes(); + return requireNonNull(resp.getBody(), "CordaClient.getVirtualNodeList: empty getBody()") + .virtualNodes(); } // public String getGemeProposals(String ) {