How do I show a Mendix exception in the client from a Java action.
I am calling a java action in a microflow. When the action throws a exception I want to catch it and use this exception further in the flow. How can I do this?
Marco de Kievit
I think it's best to create a meta object to store the information about the exception in. Let the java action return an object of this type and store the error message in it. You can also add an attribute of type boolean to the meta object to store if the java action completed successfully. Now you can use it anywhere in your microflow.
You can return false in your Java action when an error occurs and true when no error occurs.
You can use this variable in your microflow and for instance with a show message activity show an error.
Or if you want to make a difference between errors you can return a string with the error type and use this in your microflow.
Roy van der Valk
Sure. There are absolutely no model changes needed for this functionality. Use the following code within the execute function of your JAVA action: