Contact Free trial Login

try

try(() -> T): TryResult<T>

Evaluates the delegate function and returns an object with the result or an error message.

Parameters

Name Description

delegate

The function to evaluate.

Example

This example passes the fail function as an argument to try.

Source

%dw 2.0
import try, fail from dw::Runtime
output application/json
---
try(fail)

Output

{
    "success": false,
    "error": {
    "kind": "UserException",
    "message": "Error",
    "location": "Unknown location",
    "stack": [
      "main (anonymous:0:0)"
    ]
  }
}