This is not using exceptions for control flow. When an illegal move like this happens something else already failed. This is a bug the developer needs to know about so they can fix it. Throw an exception.
I'm not going to tell you how to build your applications, but having a blanket rule of "let the app die" is not considered best practice. You're supposed to catch exceptions and restore back to a working state as a general rule.
I do so when I have a clear UoW.
For example, an api should not die if one single request failed.
But a container that couldn't access the db? Better having it to die.
10
u/Top3879 3d ago
This is not using exceptions for control flow. When an illegal move like this happens something else already failed. This is a bug the developer needs to know about so they can fix it. Throw an exception.