error and "already exists" handling

+1 vote
I'm currently working on a nodejs application that uses the multichain-node package.

So far I've always created unique assets through a form by just changing the name like item1, item2, item3, ect, until the chain is so dirty I just replace it.

When it goes live however I obviously need some proper error handling.

I was thinking about catching the "already exists" error when a user clicks submit and show a message on the form. Is there a better way to check whether something like an asset already exists? I'm probably going to have lots of assets, so searching through them with listassets is not really a good option I believe.
asked May 10, 2017 by anonymous

1 Answer

0 votes
Best answer

You can pass an asset name directly to listassets to only get information about that asset, or an error if it doesn't exist. See the full set of parameters here:

answered May 10, 2017 by MultiChain