You can translate the question and the replies:

How to return query error in denodo custom function

I used denodo VDP version 8.0 i build custom function successfully. however, when there is a error proccess in function, it always return null value. how to handling the error/exception to direct stop the query process? i don't want when it happen query finish successfully and return null values i try to try catch and throw error, but it didn't worked.
user
19-08-2022 00:14:18 -0400
code

3 Answers

Hello, The return of nulls by the custom function is the expected result when there is an error. However, to record error messages in the Virtual DataPort server log for a custom function, you can add the log4j2 library to your project and then define a logger in your custom function class. You can refer to a similar Community [Q&A](https://community.denodo.com/answers/question/details?questionId=9064u000000Ceq0AAC&title=Error+Handling+with+Custom+Functions) that describes importing a log4j2 library, defining a logger, and setting the log level. By using the Denodo Virtual DataPort 8.0 Java API [getQueryContext()](https://community.denodo.com/docs/html/browse/8.0/en/vdp/javadoc/com/denodo/common/custom/elements/CustomElementsUtil.html#getQueryContext--), you can return the context information about the query executing the function and identify the query. To kill the query using these details, you can use JMX to access the monitoring information of the server. [Monitoring with a Java Management Extensions (JMX) Agent](https://community.denodo.com/docs/html/browse/latest/en/vdp/administration/monitoring_the_virtual_dataport_server/monitoring_with_a_java_management_extensions_jmx_agent/monitoring_with_a_java_management_extensions_jmx_agent) describes getting the monitoring information and auditing actions through JMX. Hope this helps!
Denodo Team
23-08-2022 14:44:38 -0400
code
thank you. but it's not ideal for me because i use the custom function to call rest API to validate the value. if there is an error like connection exception, it's like an ambiguous result. even more, i use the query to make cache view.
user
 Edited on: 23-08-2023 01:12:27 -0400
Hello, As described above, to record an error message in the Virtual DataPort server log for a custom function, adding the log4j2 library to your project and defining a logger in your custom function class is the ideal method that can be used currently. At this moment it is not possible to customize the error message returned by the custom function. Hope this helps!
Denodo Team
02-09-2022 13:44:50 -0400
code
You must sign in to add an answer. If you do not have an account, you can register here