diff --git a/src/main/java/jota/IotaAPI.java b/src/main/java/jota/IotaAPI.java index 8f21e02..9e9682b 100644 --- a/src/main/java/jota/IotaAPI.java +++ b/src/main/java/jota/IotaAPI.java @@ -1,10 +1,7 @@ package jota; import jota.dto.response.*; -import jota.error.ArgumentException; -import jota.error.InvalidBundleException; -import jota.error.InvalidSignatureException; -import jota.error.NotEnoughBalanceException; +import jota.error.*; import jota.model.*; import jota.pow.ICurl; import jota.pow.JCurl; @@ -95,7 +92,7 @@ public class IotaAPI extends IotaAPICoreProxy { * @property {bool} inclusionStates returns confirmation status of all transactions * @returns {object} success **/ - public GetTransferResponse getTransfers(String seed, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException { + public GetTransferResponse getTransfers(String seed, Integer start, Integer end, Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException, NoAddressException, NoTransactionExcpection, NoNodeInfoException { StopWatch stopWatch = new StopWatch(); // validate & if needed pad seed if ((seed = InputValidator.validateSeed(seed)) == null) { @@ -119,10 +116,10 @@ public class IotaAPI extends IotaAPICoreProxy { System.out.println("GetTransfers after bundlesFromAddresses " + sw.getElapsedTimeMili() + " ms"); return GetTransferResponse.create(bundles, stopWatch.getElapsedTimeMili()); } - return null; + throw new NoAddressException(); } - public Bundle[] bundlesFromAddresses(String[] addresses, final Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException { + public Bundle[] bundlesFromAddresses(String[] addresses, final Boolean inclusionStates) throws ArgumentException, InvalidBundleException, InvalidSignatureException, NoTransactionExcpection, NoNodeInfoException { List trxs = findTransactionObjects(addresses); // set of tail transactions @@ -278,10 +275,10 @@ public class IotaAPI extends IotaAPICoreProxy { * @returns {function} callback * @returns {object} success **/ - public List findTransactionObjects(String[] input) { + public List findTransactionObjects(String[] input) throws NoTransactionExcpection { FindTransactionResponse ftr = findTransactions(input, null, null, null); if (ftr == null || ftr.getHashes() == null) - return null; + throw new NoTransactionExcpection(); // get the transaction objects of the transactions return getTransactionsObjects(ftr.getHashes()); @@ -297,10 +294,10 @@ public class IotaAPI extends IotaAPICoreProxy { * @returns {function} callback * @returns {object} success **/ - public List findTransactionObjectsByBundle(String[] input) { + public List findTransactionObjectsByBundle(String[] input) throws NoTransactionExcpection { FindTransactionResponse ftr = findTransactions(null, null, null, input); if (ftr == null || ftr.getHashes() == null) - return null; + throw new NoTransactionExcpection(); // get the transaction objects of the transactions return getTransactionsObjects(ftr.getHashes()); @@ -679,9 +676,9 @@ public class IotaAPI extends IotaAPICoreProxy { * @returns {function} callback * @returns {array} state **/ - public GetInclusionStateResponse getLatestInclusion(String[] hashes) { + public GetInclusionStateResponse getLatestInclusion(String[] hashes) throws NoNodeInfoException { GetNodeInfoResponse getNodeInfoResponse = getNodeInfo(); - if (getNodeInfoResponse == null) return null; + if (getNodeInfoResponse == null) throw new NoNodeInfoException(); String[] latestMilestone = {getNodeInfoResponse.getLatestSolidSubtangleMilestone()}; diff --git a/src/main/java/jota/error/NoAddressException.java b/src/main/java/jota/error/NoAddressException.java new file mode 100644 index 0000000..93752b8 --- /dev/null +++ b/src/main/java/jota/error/NoAddressException.java @@ -0,0 +1,11 @@ +package jota.error; + +/** + * Created by Adrian on 22.01.2017. + */ +public class NoAddressException extends BaseException { + + public NoAddressException() { + super("Not address found for the provided seed"); + } +} \ No newline at end of file diff --git a/src/main/java/jota/error/NoNodeInfoException.java b/src/main/java/jota/error/NoNodeInfoException.java new file mode 100644 index 0000000..920c6f3 --- /dev/null +++ b/src/main/java/jota/error/NoNodeInfoException.java @@ -0,0 +1,11 @@ +package jota.error; + +/** + * Created by Adrian on 22.01.2017. + */ +public class NoNodeInfoException extends BaseException { + + public NoNodeInfoException() { + super("Node info could not be retrieved"); + } +} \ No newline at end of file diff --git a/src/main/java/jota/error/NoTransactionExcpection.java b/src/main/java/jota/error/NoTransactionExcpection.java new file mode 100644 index 0000000..f2b3138 --- /dev/null +++ b/src/main/java/jota/error/NoTransactionExcpection.java @@ -0,0 +1,11 @@ +package jota.error; + +/** + * Created by Adrian on 22.01.2017. + */ +public class NoTransactionExcpection extends BaseException { + + public NoTransactionExcpection() { + super("Not transactions for the provided seed"); + } +}