DataWeave: Explicit dw::Runtime Import Required to Use Try Function

A DataWeave developer discovered that the try() function fails to resolve at runtime unless explicitly imported from the dw::Runtime module, as it is not available by default. The error 'Unable to resolve reference of: try' is thrown with an exit code of 255 when the import statement is omitted. The fix is to add 'import try from dw::Runtime' at the top of any script using the function. When correctly implemented, the try() function can catch type-coercion failures and return RFC 7807-compliant error responses, including fields such as type, title, status, detail, and instance. The developer recommends verifying the import exists before running any transformation to prevent resolution errors.
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