Skip to content
Discussions/App Development/React - try catch of ledger.exercise issueForum ↗

React - try catch of ledger.exercise issue

App Development18 posts702 views2 likesLast activity Jul 2020
AL
alexanderOP
Jul 2020

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

CO
cocreature
Jul 2020

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.

AL
alexander
Jul 2020

Hi, @cocreature Thanks for your fast response.

Actually I already tried as you mentioned in other ticket but it didn’t solve current issue :frowning:

AL
alexander
Jul 2020

Of course Warning message in JSON-API it’s related to current issue i think also.

CO
cocreature
Jul 2020

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 the yarn.lock as well at Daml-ui-template React function and Action with 2 arguments? Note that you should do that before running the other steps.

AL
alexander
Jul 2020

Okay let me try to follow your suggestion right now.

AL
alexander
Jul 2020

Still same. I removed yarn.lock & node_modules & yarn install with out any parameters but still same issue :frowning:

CO
cocreature
Jul 2020

Not quite sure what could be going wrong there. Is your project available publicly somewhere?

AL
alexander
Jul 2020

Not available at the moment.

CO
cocreature
Jul 2020

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.

AL
alexander
Jul 2020

I always get errors. And version of SDK is 1.1.1

CO
cocreature
Jul 2020

Have you tried upgrading to 1.2.0?

AL
alexander
Jul 2020

I didn’t test it with 1.2.0

AL
alexander
Jul 2020

What is the function of daml codegen js -o daml2js daml/model/.daml/dist/*.dar?

GA
Gary_Verhaegen
Jul 2020

It generates JS/TS files in the folder daml2js based on the types defines in the DAR file daml/model/.daml/dist/*.dar.

AL
alexander
Jul 2020

Where is daml/model located ? I am on ubuntu at the moment.

GA
Gary_Verhaegen
Jul 2020

If you do not have a daml/model folder 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/dist folder to be created by the daml build command in the same folder where your daml.yaml file is.

AL
alexander
Jul 2020

After upgraded version, it’s fixed. Thanks :slight_smile:

← Back to Discussions