React - try catch of ledger.exercise issue
- alexanderOP
Hi, I’ve met some strange issue.
Here is my code snippet;
try {
await ledger.exercise(Main.Network.InviteCitizen, contractId, { … } )
} catch (error) {
console.log("error: " + error);
}Issue is it always takes to catch with error. In my opinions, it happens because of error in ledger.exercise func. It says “Error: Trying to look up template 92332076d3b238b61e42ee43f7a2dc113348507827f7f86a6102e8013b5f247d:Main:CitizenInvitation.”
It’s very urgent and pls help me asap.
Thanks,
Alexander - cocreature
Hi @alexander,
That usually arises if your codegen ends up in an inconsistent state somehow.
Take a look at my explanation at Warning message in JSON-API " Illegal header: Illegal 'origin' header: Illegal origin: Invalid input '/" and in particular the link to the steps in Daml-ui-template React function and Action with 2 arguments that should hopefully resolve your issue. - alexander
Hi, @cocreature Thanks for your fast response.
Actually I already tried as you mentioned in other ticket but it didn’t solve current issue

- alexander
- cocreature
The JSON-API warning is unrelated and only a warning (for now, it will turn into an error in future SDK version).
Did you see the suggestion to delete theyarn.lockas well at Daml-ui-template React function and Action with 2 arguments? Note that you should do that before running the other steps. - alexander
Okay let me try to follow your suggestion right now.
- alexander
Still same. I removed yarn.lock & node_modules & yarn install with out any parameters but still same issue

- cocreature
Not quite sure what could be going wrong there. Is your project available publicly somewhere?
- alexander
Not available at the moment.
- cocreature
Which SDK version are you using and have you upgraded from a previous version or is this a fresh project? Also did it work at some point and things broke or did you always get this error.
- alexander
I always get errors. And version of SDK is 1.1.1
- cocreature 1
Have you tried upgrading to 1.2.0?
- alexander
I didn’t test it with 1.2.0
- alexander
What is the function of
daml codegen js -o daml2js daml/model/.daml/dist/*.dar? - Gary_Verhaegen
It generates JS/TS files in the folder
daml2jsbased on the types defines in the DAR filedaml/model/.daml/dist/*.dar. - alexander
Where is daml/model located ? I am on ubuntu at the moment.
- Gary_Verhaegen
If you do not have a
daml/modelfolder in your current working directory, there is little chance of that command working. Where did you get the command from? In general, you can expect the.daml/distfolder to be created by thedaml buildcommand in the same folder where yourdaml.yamlfile is. - alexander 1
After upgraded version, it’s fixed. Thanks
