If you create an exception in your ControllerFactory when creating the controller first, you will not be able to handle the exception in the action method.
Personally, I would just do a try / catch, instantiate some error handling controller, and route the request through it.
The best question is: which controllers are so dependent on what is not being implemented that they have to throw exceptions when they are being built? Allegedly, just creating controllers should not be a huge source of exceptions. If this is the case, perhaps you could lazily create dependency instances in the action methods (and not in the constructor) and implement the ErrorHandlingController approach. This will result in a down exception in the controllers themselves, so you can use a more controller-oriented approach for their processing.
source share