try($eval, $catch)
The function works with two parameters:
message and the value.I18NException the ResKey, otherwise the error message as text.throw(). null if the error did not originate from a throw() or throw() was called without a value.| 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 two arguments: the error message and the value passed via throw() (value). |
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.