Catch party not allocated error

I’m using daml 1.4.0-snapshot.20200729.4851.0.224ab362 with --implicit-party-allocation set to false.
I got grpc error Status(3,Party not known on ledger: Not all parties known,Vector()) when exercise choice using a party yet to be allocated.

I need to catch this error and provide operational guidance to allocate party.

But there is no party information in the error and the error only contain a “magical” string Party not known on ledger: Not all parties known to indicate the error is related to party not allocated.

Is there a way to properly catch this error? or is there a plan to produce more useful error?

4 Likes

I think the short answer is “no”. You can catch the error based on status code, because 3 maps to INVALID_ARGUMENT. However, this may not be sufficiently granular for your purposes.

The ledger API currently doesn’t provide any kind of structure for errors beyond the GRPC status codes. Unfortunately, for now, if you want to know more, you need to examine the error message string. I don’t want to encourage this because the content of the error message is not a defined part of the API and may change later. It also makes your own code hideous.

I’ve created issue #7004 to track this. Please feel free to comment further on your needs either here or on that issue.

3 Likes