Error Handling from a Runner’s Perspective
Did you know that the three largest marathons in Europe have more than 40,000 runners, and the most popular European run is in Paris with about 48,000 runners? It has been reported that about 30% (14,400) of the runners end up having injuries.
Some runners will ignore the injury and continue the race. Some need to take another approach, which makes them stop their current flow and take on a different running pace, posture, or strategy. There are also injuries that require the runner to completely stop, which means no finish.
When we bring this idea to Mendix and translate the marathon into a microflow where the injury is an error, the way a runner responds to the injury is similar to how we, as Mendix developers, respond to an error with error handling.
Imagine there is a light injury: a foot hurts because there is a little stone in the shoe that can easily be removed. The runner notices the injury, removes the stone, and continues running as if nothing happened. In Mendix, we can ignore an error by using the ‘Continue’ error handling, which means fix the little bump and move on.
When the situation is worse than just a little stone and there is also a wound, the runner needs to consider whether to stop the race or continue. If the runner continues, he or she needs to take a different approach — perhaps less speed or placing the wounded foot differently. Whatever it is, the current marathon running flow stops, and an alternative running strategy is now followed. In Mendix, we have ‘Custom error handling without rollback,’ which means we keep what we have done so far, but based on the issue we face here, we need to start an alternative path to continue the marathon.
When the runner feels that the injury is too much and there is no way to continue, he or she will quit the race. This means that instead of proceeding on the current marathon running flow, an alternative process will be taken, which includes being taken off the track and seeking medical support. In addition, quitting the current marathon running flow also means that the previous actions such as starting the race, checkpoints, and race-related times are irrelevant and will be erased since all that doesn’t matter anymore. By quitting the race, no times are recorded as they would be when the runner finished the marathon. In Mendix, we call this ‘Custom error handling with rollback,’ which means when an error occurs, erase all that was done before the error and start a new microflow as the error flow.
Regardless of whether the runner continues or quits the marathon, it is in both situations a very good idea to look carefully at what the injury is. Having a good understanding of what happens can prevent further injuries. This is the same when it comes to Mendix. Always write a well-detailed error log in your error flow in order to prevent future errors, and in case of a real emergency, it helps you understand the nature of the error faster and better.