Skip to content

Commit

Permalink
[FAJ-502]-Add exception log (#34)
Browse files Browse the repository at this point in the history
* Add exception log [FABJ-502]

Signed-off-by: lesleyannj <lesleyannj@hotmail.com>
  • Loading branch information
lesleyannjordan authored and bestbeforetoday committed Dec 20, 2019
1 parent e94ff5e commit 876169c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/java/org/hyperledger/fabric/sdk/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -5537,6 +5537,21 @@ Collection<String> getIgnoreList() {
*/
public CompletableFuture<TransactionEvent> sendTransaction(Collection<? extends ProposalResponse> proposalResponses,
TransactionOptions transactionOptions) {
return doSendTransaction(proposalResponses, transactionOptions)
.whenComplete((result, exception) -> logCompletion("sendTransaction", result, exception));
}

private <T> T logCompletion(final String message, final T result, final Throwable exception) {

if (exception != null) {
logger.error("Future completed exceptionally: " + message, exception);
}
return result;
}

private CompletableFuture<TransactionEvent> doSendTransaction(Collection<? extends ProposalResponse> proposalResponses,
TransactionOptions transactionOptions) {

try {
if (null == transactionOptions) {
throw new InvalidArgumentException("Parameter transactionOptions can't be null");
Expand Down Expand Up @@ -5712,13 +5727,11 @@ public CompletableFuture<TransactionEvent> sendTransaction(Collection<? extends

CompletableFuture<TransactionEvent> ret = new CompletableFuture<>();
ret.completeExceptionally(lException != null ? new Exception(emsg, lException) : new Exception(emsg));
logger.error(emsg);
return ret;
}
} catch (Exception e) {
CompletableFuture<TransactionEvent> future = new CompletableFuture<>();
future.completeExceptionally(e);
logger.error(e);
return future;
}
}
Expand Down

0 comments on commit 876169c

Please sign in to comment.