Nav

try

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

Evaluates the delegate (a lambda without inputs) and returns an object with the result or an error message.

Example

        
     
1
2
3
4
5
%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": [

     ]
   }
}