Although I wrote that exceptions will be converted to messages on the UI, most of the messages we see often should not involve exceptions. This is partly because errors in user input should be detected (validated) at the time of entry, not while the request is being processed. These errors don’t need to involve exceptions.Having said that, there are cases where exceptions do lead to messages on the UI. I will explain a little on how this can be done.
Before that, I need to remind you of two modes of messages and two ways of handling errors.
These are concepts that are similar, but different in what is stopped. One stops the user. The other stops the thread. Care should be taken when choosing how to deliver a message. If we use modal or synchronous messages unnecessarily, we would end up with a frustrating piece of software. There are also different kinds of users to which a message would be directed.
Once you choose the method, it should be obvious how to do the programming. It should very rarely be the case that a raw exception message is shown by throwing the exception directly to the UI framework. In other words, the Presentation layer has the work of converting the exceptions that it caught into the message of choice. |
Contents |