Skip to content

Commit 66e9d81

Browse files
authored
Merge pull request #216 from OYamkovyy/FCJ-214
FCJ-214 improved ChaincodeRuntimeException message
2 parents 4d65b7c + 16f6a6f commit 66e9d81

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/execution/impl/ContractExecutionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public Chaincode.Response executeRequest(final TxFunction txFn, final Invocation
7676
if (cause instanceof ChaincodeException) {
7777
response = ResponseUtils.newErrorResponse(cause);
7878
} else {
79-
throw new ContractRuntimeException("Error during contract method execution", cause);
79+
throw new ContractRuntimeException(String.format("Error during contract method execution: %s", cause.getMessage()), cause);
8080
}
8181
}
8282

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/impl/ChaincodeInvocationTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ protected ByteString invoke(final ChaincodeMessage message) {
217217
logger.fine(() -> String.format("[%-8.8s] Successful response received.", txId));
218218
return response.getPayload();
219219
case ERROR:
220-
logger.severe(() -> String.format("[%-8.8s] Unsuccessful response received.", txId));
221-
throw new RuntimeException(String.format("[%-8.8s]Unsuccessful response received.", txId));
220+
logger.severe(() -> String.format("[%-8.8s] Unsuccessful response received: %s.", txId, response.getPayload().toStringUtf8()));
221+
throw new RuntimeException(String.format("[%-8.8s]Unsuccessful response received: %s.", txId, response.getPayload().toStringUtf8()));
222222
default:
223223
logger.severe(() -> String.format("[%-8.8s] Unexpected %s response received. Expected %s or %s.", txId,
224224
response.getType(), RESPONSE, ERROR));

fabric-chaincode-shim/src/test/java/org/hyperledger/fabric/contract/ContractRouterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public void testInvokeTxnThatThrowsAnException() {
346346
final Chaincode.Response response = r.invoke(s);
347347
assertThat(response, is(notNullValue()));
348348
assertThat(response.getStatus(), is(Chaincode.Response.Status.INTERNAL_SERVER_ERROR));
349-
assertThat(response.getMessage(), is(equalTo("Error during contract method execution")));
349+
assertThat(response.getMessage(), is(equalTo("Error during contract method execution: T3 fail!")));
350350
assertThat(response.getStringPayload(), is(nullValue()));
351351
assertThat(SampleContract.getBeforeInvoked(), is(1));
352352
assertThat(SampleContract.getAfterInvoked(), is(0));

0 commit comments

Comments
 (0)