The type of handleError function is
:: (e -> Contract w s e' a)-> Contract w s e a -> Contract w s e' a
It takes two arguments
- a function which takes error and returns a Contract monad
(Contract w s e' a)
without error - Contract Monad with error
and returns a Contract Monad without error (Contract w s e a)
. This is what I could understand. However when this is used in the following code
payContract = do
pp <- endpoint @"pay"
let tx = mustPayToPubKey (ppRecipient pp) $ lovelaceValueOf $ ppLovelace pp
handleError (\err -> Contract.logInfo $ "caught error: " ++ unpack err) $ void $ submitTx tx
payContract
In this function call submitTx Tx
gives the Contract Monad with error and the lambda function \err -> Contract.logInfo $ "caught error: " ++ unpack err
may be the first argument. What is happening to the returned Monad without error? and why void is used?