hyperledger / fabric-chaincode-java

Hyperledger Fabric Contract and Chaincode implementation for Java
https://hyperledger.github.io/fabric-chaincode-java/
Apache License 2.0
304 stars 207 forks source link

Fabric-shim-java needs to return a nested exception #247

Closed deeptiraom closed 2 years ago

deeptiraom commented 2 years ago

Its observed that the fabric-chaincode-shim throws ContractException in case of exception in Chaincode however it needs to return the actual cause nested / wrapped inside the chaincode exception. This is required to fetch the nested exception which is the actual cause in the client sdk adapter when used to run marvin

deeptiraom commented 2 years ago

I am trying to fetch the nested exception in the client sdk but its not present:

image
jt-nti commented 2 years ago

Hi @deeptiraom, the chaincode SDK deliberately does not return stack traces with the cause to client applications to avoid leaking potentially sensitive information. Chaincode implementations should use ChaincodeException to provide application level error information to the client SDK.

jt-nti commented 2 years ago

There's an example of handling errors such as the sample asset not found in the REST sample which may be useful... https://github.com/hyperledger/fabric-samples/blob/main/asset-transfer-basic/rest-api-typescript/src/errors.ts