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)"
    ]
  }
}

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.