Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Java client error-handling example #1262

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

bestbeforetoday
Copy link
Member

@bestbeforetoday bestbeforetoday commented Oct 18, 2024

The latest fabric-gateway client API release (v1.7.0) includes the gRPC error details in the GatewayExcetion stack trace so it is not necessary to programmatically access them to demonstrate that they are present.

This change updates the asset-transfer-basic/application-gateway-java sample to simplify the updateNonExistentAsset example method. It also:

  • Updates all samples to use the latest fabric-gateway release.
  • Adds equivalent Maven POM files for fabric-gateway application samples.

The additional testing of running the Java client applications using first Gradle and then Maven identified an inconsistency in behaviour between the Java implementation of the asset-transfer-basic smart contract and all the other language implementations. In only the Java implementation, the InitLedger call failed if the assets already existed, which meant that the sample client applications could only be run once. A subsequent run (without clearing the ledger) resulted in an endorsement failure on the InitLedger call. This change fixes that behaviour and makes the Java implementation consistent with the other language implementations.

Closes #747

@bestbeforetoday bestbeforetoday marked this pull request as ready for review October 18, 2024 17:47
@bestbeforetoday bestbeforetoday requested a review from a team as a code owner October 18, 2024 17:47
@bestbeforetoday bestbeforetoday force-pushed the java-error-details branch 3 times, most recently from 2ed3d44 to 33d6397 Compare October 20, 2024 00:17
The latest fabric-gateway client API release (v1.7.0) includes the gRPC error
details in the GatewayExcetion stack trace so it is not necessary to
programmatically access them to demonstrate that they are present.

This change updates the asset-transfer-basic/application-gateway-java
sample to simplify the updateNonExistentAsset example method. It also:

- Updates all samples to use the latest fabric-gateway release.
- Adds equivalent Maven POM files for fabric-gateway application samples.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
Comment on lines -238 to -245
var details = e.getDetails();
if (!details.isEmpty()) {
System.out.println("Error Details:");
for (var detail : details) {
System.out.println("- address: " + detail.getAddress() + ", mspId: " + detail.getMspId()
+ ", message: " + detail.getMessage());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So glad we don't have to traverse the details now!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still access them programmatically (as before) if you need to buy this gives a much smoother user experience when things go wrong. I'm wondering if there is anything that can be done better for Go too.

@denyeart denyeart merged commit e23bc67 into hyperledger:main Oct 25, 2024
38 checks passed
@bestbeforetoday bestbeforetoday deleted the java-error-details branch October 25, 2024 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

application-gateway-java not working
2 participants