Re-Raising an Exception
1271
Views
6
Comments
New
Backend

In an exception handler, it should be possible to re-raise the original exception if it could not be appropriately handled using the same Exception type for processing further down the line.

Currently we have access to the ExceptionMessage but NOT the Exception (type) meaning that if we re-raise the exception we have to choose a type (which we typically don't know).  I end up having to create an "UnknownException" type even though the original may have been a standard type so it may not be appropriately caught later down the chain.

Changed the category to
Backend

I stumbled upon this today (again!)

2025-02-22 18-27-01
Alfaro
 
MVP
Merged this idea with 'Ability to rethrow exception' (created on 26 Sep 2018 15:01:05 by Igor Kirtak)

I think this should have been posted already, but I could not find it.

Would be good to have ability to rethrow an exception in exception handler - preserving it's type and message and (ideally) stack trace - similar to what C# statement "throw;" would do.

The problem is: we have global OnException handler in the application, which catches SecurityException and if it shows that login has expired - redirects to login screen. But there are also own exception handlers inside of some actions, which catch AllExceptions for their own reason and this way the above global handler is not involved. I know I can make those actions catch all types of exceptions except SecurityException, but this means a lot of copy-paste (example is below). Would be good and neat if they could catch AllExcepions, do whatever they need, and then throw it for global handler to do the rest. But this won't work because I can throw only UserException or AbortActivity, plus there is no way to know concrete type in AllExceptions handler.



This comment was:
- originally posted on idea 'Ability to rethrow exception' (created on 26 Sep 2018 by Igor Kirtak)
- merged to idea 'Re-Raising an Exception' on 24 Jul 2020 16:11:03 by Carlos Alfaro
Changed the category to
Backend


This comment was:
- originally posted on idea 'Ability to rethrow exception' (created on 26 Sep 2018 by Igor Kirtak)
- merged to idea 'Re-Raising an Exception' on 24 Jul 2020 16:11:03 by Carlos Alfaro

can be merged with this one ? https://www.outsystems.com/ideas/5023/re-raising-an-exception



This comment was:
- originally posted on idea 'Ability to rethrow exception' (created on 26 Sep 2018 by Igor Kirtak)
- merged to idea 'Re-Raising an Exception' on 24 Jul 2020 16:11:03 by Carlos Alfaro