try($eval, $catch)
The function works with two parameters:
| Name | Type | Type Description | Mandatory | Standard |
|---|---|---|---|---|
|
eval |
Code block / expression | The code block or expression that is to be executed. | yes | - |
| catch | Function | The fallback function that is executed when an error occurs. Receives the exception object as a parameter | no | null |
Type: Object
nullis returned in the event of an error.
try(
sendMail(
subject: $subject,
to: $emailAddr,
body: $emailBody
),
catch: mailError -> {
info("E-Mail-Zustellung an " + $emailAddr + " fehlgeschlagen. Grund: " + $mailError);
false
}
)
Output: Attempts to send an e-mail. If successful, the result of sendMail is returned. If an error occurs, false is returned and a user info with the attempted e-mail address.