Hi all,
Could you help me to differentiate these two tools?
RaiseException and Exception_Handler
Although I have read about them in the documentation, I still have doubts about when to use one or the other.
https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Implementing_Logic/Mobile_Logic_Tools/Raise_Exception
https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Implementing_Logic/Mobile_Logic_Tools/Exception_Handler
https://success.outsystems.com/Documentation/11/Developing_an_Application/Implement_Application_Logic/Handle_Exceptions
Best regard,Jessica Marques.
Hi Jessica,
You may have realized that when you create a screen action, platform automatically places an Exception Handler that handles "All Exceptions". This is to catch all kinds of unexpected errors that may occur in the action.
You can create more exceptions with a name you like in the Logic/Exceptions folder, and then raise them as you like in the action. In the following example, I created a NoUserFound Exception, and put a handler for it next to the default AllExceptions handler. And I raise the NoUserFound Exception when the user I'm looking for is not present in the entity.
This way, I can tell the platform to do specific things (e.g log a specific type of error to an external system) according to the exception.
Ozan Cali wrote:
Hi Ozan,
Perfect!I believe that you have essentially understood where and how I will use these two elements. I created a sketch, according to your example, to test it.Thank you very much for your help and for the examples, they were indeed very informative.Best Regards,Jessica Marques.
Glad to be of help, Jessica Marques!
Thanks for the explanation.
Raise Exception is when you find an error and want to raise it.
Exception handler is to catch exceptions raised by you or the system and handle them gracefully.
Let me know if you need more information.
Regards,
Marcelo
Marcelo Ferreira wrote:
Hi Marcelo,
Honestly, I'm still confused, the raise exception is the main element that I have doubts in this case. Because in most of the flows I saw, the system generates an Exception handler, with the feedback message and the end, this element is outside the main flow, and as you said, it will catch exceptions raised by you or the system.But what about the raise exception, when will I specifically use it? what is the difference in practice between "find an error" and "to catch exceptions"?Could you give me a practical example of when I should use both?
Jessica.