Throw an exception to another module

It is possible to throw an exception to another module of the same app?
Web

Hi Julio,

Yes you can do it.

Step1-  handel error and return error as output from action like below image


Step2- call this action in another module and get retrun error in local variable and show in expression or feedback message.


Step3 Result is


Hope this will help you,

Regards

Rahul sahu

Hi Júlio,

I'm not sure I understand what you mean. Is your question the same as posed in this post?

If that is the case, take a look at the explanation provided by Kilian. 

If you have further questions or your case is different, please let us know.

Hope this helps.

Regards,

Nordin

Rahul Sahu Okay, and for another case, if I have an specific exception, can I handle it in another module like the previous example?

Hi Julio,

You could of course re-raise that exception with the same error message.


After that, you can handle the re-raised exception in the calling module.

And the Feedback message will show the Error message.

Hope this helps.

Regards,

Nordin

Solution

Júlio Chaby wrote:

Rahul Sahu Okay, and for another case, if I have an specific exception, can I handle it in another module like the previous example?

 

 Hi Julio,

the answer to that one is no.  When going from one module to another, the exception looses it's specificity.  You can still catch it in an AllExceptions handler (like the example by Nordin), but you loose the information that it was the InvalidPostalCode exception.

I was looking at this a week or 2 ago, and this also depends on whether it's traditional or reactive, I was in the midlle of making some demo oml's for this, I'll see to post them here tonight.

Dorine

Solution

Hi,

 I tried some user and role exceptions in both tradional and reactive.  Found some unexpected behaviour.


specific user exceptions 

loose specificity across producer-consumer relation.  You couldn't even write a handler in consumer if you wanted, as the exceptions don't have the option of being made public, so the consumer module doesn't know about their existence. In Traditional they get caught in UserException Handler, in Reactive in AllExceptions Handler.  Very sad that there isn't even consistency.

Not Registered exception

very good in traditional, gets handled by notRegistered handler, even if raised in producer module.  Very disappointing in Reactive, both notRegistered raised in own module as in other module, get handled by SecurityException handler.  In other words, there is never a point in using the notRegistered handler in reactive.

not role X exception

It is possible to write a notRoleX handler, even if this role is from producer, as it can be made public.  So this looks promising, and in reactive it also works as expected, unfortunately, in traditional it doesn't, it gets handled by the more generic notRegistered handler if set in a producer module, which really doesn't make sense, as user is registered, he just doesn't have the right role.


conclusion, beware when setting up some fancy exception handling, as things might not work quite as expected.

Dorine

and this is reactive demo