java – Where should exception handling be performed to display to the system user?


What is the best place to handle an exception and send a message to the system user in a desktop application? In the controller, in the view or elsewhere?


On the controller.

Your model layer can throw exceptions if you try to perform some disallowed operation or if the operation to be performed fails.

The controller then catches this error and decides how the view layer will display it.

The view layer is responsible for showing the error, and perhaps capturing a user action telling you what to do. But it is not her responsibility to handle the error.

Error handling is part of application flow control. And flow control is the controller's responsibility.

Scroll to Top