@cocreature @akrmn I am trying to catch exceptions in DAML Triggers that occurred by exercising some choice. And I want to create another contract when I catch the exception.
when (isSome bondToken) do
let bondTokenContractId = fst $ fromSome bondToken
now <- getTime
let isSender = (\part -> part.system == m.system)
let replyTo = List.head $ filter (\(_, part) -> isSender part) parts
try do
T.dedupExercise bondTokenContractId (BondToken_Model.Tranfer_Bond_Tokens cakEscrowAccount numberOfTokens)
debug $ "Bond token transferred for " <> show settlementInstructionData.transactionId
whenSome replyTo $ \(system, _) ->
T.dedupExercise system (Load.Create_Cash_Transfer_Request)
catch
(InsufficientBalanceException _ _) -> do
debug $ "error occurred"
T.dedupCreate ABCTemplate with a=a, b=b
But it is giving me below error
• No instance for (ActionCatch (TriggerA ()))
arising from a use of ‘_tryCatch’
• In a stmt of a 'do' block:
_tryCatch
\ _
-> do dedupExercise
bondTokenContractId
(Tranfer_Bond_Tokens cakEscrowAccount numberOfTokens)
debug
$ "Bond token transferred for "
<> show (getField @"transactionId" settlementInstructionData)
....
\case
fromAnyException -> Some (InsufficientBalanceException _ _)
-> Some
do debug $ "error occurred"
dedupCreate
CashReversalRequest
{endToEndId = (getField @"endToEndId" m),
customerRef = (getField @"customerRef" m),
payer = (getField @"payer" m),
payerAccount = (getField @"payerAccount" m),
payee = (getField @"payee" m),
payeeAccount = (getField @"payeeAccount" m),
instructedMvUnit = (getField @"instructedMvUnit" m),
instructedMvType = (getField @"instructedMvType" m),
remittanceInfo = (getField @"remittanceInfo" m), createTime = now,
settlementBank = (getField @"settlementBank" m), observers = ...,
valueDate = (getField @"valueDate" m),
chargeBearer = (getField @"chargeBearer" m),
purposeCode = (getField @"purposeCode" m), reversalType = LOAD,
requestor = (getField @"system" m)}
_ -> None
In the second argument of ‘when’, namely
‘do let bondTokenContractId = fst $ fromSome bondToken
now <- getTime
let isSender = (\ part -> ...)
let replyTo = List.head $ filter (\ (_, part) -> ...) parts
....’
In a stmt of a 'do' block:
when
(isSome bondToken)
do let bondTokenContractId = fst $ fromSome bondToken
now <- getTime
let isSender = (\ part -> ...)
let replyTo = List.head $ filter (\ (_, part) -> ...) parts
....typecheck
How to resolve this?