Is there a way to return `assertMsg` error messages defined in the Daml code to the UI?
- gyorgybalazsiOP 1
In the Create Daml App example from the docs, the Daml code defines error messages in the
assertMsgsatements of theFollowchoice:-- FOLLOW_BEGIN nonconsuming choice Follow: ContractId User with userToFollow: Party controller username do assertMsg "You cannot follow yourself" (userToFollow /= username) assertMsg "You cannot follow the same user twice" (notElem userToFollow following) archive self create this with following = userToFollow :: following -- FOLLOW_ENDThough when I try to follow myself I get this error message:
The message comes from this code in the
MainView.tsxfile:// FOLLOW_BEGIN const ledger = useLedger(); const follow = async (userToFollow: Party): Promise<boolean> => { try { await ledger.exerciseByKey(User.User.Follow, username, {userToFollow}); return true; } catch (error) { alert(`Unknown error:\n${error}`); return false; } } // FOLLOW_END - Stephen 2
What do you get in the alert when you format
errorto JSON before string-interpolating it? - gyorgybalazsi 1

