In the Create Daml App example from the docs, the Daml code defines error messages in the assertMsg
satements of the Follow
choice:
-- 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_END
Though when I try to follow myself I get this error message:
The message comes from this code in the MainView.tsx
file:
// 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