New LedgerAPI Error codes

Daml 1.18 introduced new (or more detailed) Error Codes from the gRPC api. I assume that we should be able to see some of these on the completion API and in particular the CompletionStreamResponse. But I can’t figure out how to access them from these Java functions. Is this information in a different place?

There are improvements to be made in terms of usability, but if I understand correctly the error codes consist of information added to the gRPC Status, so you should be able to use the getStatus method on the completions returned by getCompletions and see the error details in there.

1 Like

Indeed @stefanobaghino-da .

All the error code details are packed in the status payload of the Completion. There you can inspect the human-readable error message via getMessage. The machine-readable information is packed in the error details (see getDetailsList) from which you can extract programatically by checking the contents of the returned list:

  • the ErrorInfo contains the self-service error code id (ErrorInfo#getReason) and additional failure key-value metadata (ErrorInfo#getMetadataMap).
  • the RequestInfo#getRequestId is the error correlation-id (submission-id) if available.
  • the RetryInfo#getRetryDelay instructs the client when to retry if the error is retryable.
  • the ResourceInfo, if present, contains the resource name and the value to which the failure pertains (e.g. for CONTRACT_KEY_NOT_FOUND, the status will contain a ResourceInfo expanding to CONTRACT_KEY<the-key-which-was-not-found>)

An explicit example on how to extract these with the Java gRPC API is available here

3 Likes

@tudor_voicu Thank you for the detailed answer! I did not realize that Status was an object and not just an integer ( I was confused by the logs which just showed the statusCode).

1 Like