DataWeave Try Function Requires Explicit Import from dw::Runtime to Avoid Errors

A DataWeave script using the try() function will fail with an 'Unable to resolve reference' error if dw::Runtime is not explicitly imported at the top of the script. The try() function, which returns a Result object for error handling, is not available by default and must be imported with 'import try from dw::Runtime'. When applied to invalid input — such as a malformed number string like '12.5O' — the function captures the error details without crashing the transformation. The script can then return an RFC 7807-compliant error response, including fields like type, title, status, detail, and instance. Developers are advised to verify the import exists before executing any transformation that relies on the try() function.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in