Question concerning learning path Learn How to Handle Errors

0
Hi there, I've been going through the learning path about Error Handling (Learn How to Handle Errors) and I have build some of the examples in a Test App to understand the concept. There are some scenario's whom I build where the results did not match the examples in the knowledge check in module 4.    For example the attached scenario from the knowledge check (Example from knowledge check).     (https://academy.mendix.com/link/modules/32/lectures/207/4.3-Knowledge-Check-%E2%80%93-Advanced-Error-Handling-Situations). According to the knowledge check, the right answer would be that everything will be committed, except the OrderLine.  I build this scenario in a Test App and the results deviate from the knowledge check, find attached (Build scenario in Test App).    In my Test App, with the same scenario, only Klant (=Order) & Gebouw(=Customer) are committed, and not Product (=EmailLog). So this seems to deviate from the knowledge check question 2.   I published the app to the cloud and it is reachable using below link:  https://errorhandlingadvancedexamen-sandbox.mxapps.io/index.html?profile=Responsive The app is named "ErrorHandlingAdvancedExamen". Find attached screenshot of the home page (Home page Test app) With "Click me please" above scenario is testable. The datagrids are updated with the newly created objects. With "data ophalen" and debugging the attached flow, you can see which objects are in the DB as well (apart from the datagrids on the home page).  Same goes for question 5 where I see in my Test app that only Klant (=Order) & Gebouw(=Customer) are committed, and not Bedrijf(=OrderLine) & Product (=EmailLog). Could you please clarify whether the questions 2 and 5 in the knowledge check are wrong, or am I missing something? How is the errorhandling supposed to work exactly? Thank you! Tim
asked
1 answers
4

I would have expected in your case that the Klant object is committed, as well as the Gebouw object and the Product object.

In the sub MF the rollback is performed on the actions before the error is thrown, so the Bedrijf object is rolled back.

In the custom handling the Product object is created after the error was thrown. The error is passed back to the calling MF, this has error handling without rollback so the Klant object is not rolled back and in the custom handler the Gebouw object is created after the rollback so this should be in the database.

However it seems that by rethrowing the error in the error event the custom create with commit action is rolled back as well.

The plot thickens even more in the following case:

A MF triggered from a button calls a MF with error handling set to custom without rollback:

The called microflow creates object A, calls MF_2 and when an error is recieved from MF_2 creates Object B without roll back and the error is rethrown.

MF_2 creates a variable to make sure to throw an error, then in the error handler with rollback Object C is created and a log message is displayed and the error is rethrown:

The result of this is that neither object A, B nor C is created, while object C should be created in the error handler, the same holds true for object C and Object A is not rolled back so should be committed.

Long answer short the answer to the question in the learning path is wrong and additional documentation on error handling in combination with rethrowing errors is needed IMHO.

answered