Chapter 9. Exceptions and Message Boxes: Get the message?

Sometimes things just go wrong. You just need to handle it.
There will always be things beyond your control. Networks will fail. Files will disappear. Smart coders learn how to deal with those kinds of errors and make their programs recover gracefully. The best software keeps the user informed about the bad things that happen and what should be done to recover. By learning how to use exceptions and message boxes, you can take your software to the next level of reliability and quality.
What’s that smell?
Just when it looked like things were going so well, there was a problem in the Head-Ex storeroom.

A trainee was recording the consignment of cheese when there was a problem that prevented the program from recording the delivery. That meant the cheese was never assigned to a delivery truck. So the cheese never left the storeroom and it just sat there for a very long time. And that meant—well, you can just imagine...
To prevent the same thing happening again, you need to find what caused the problem.
Someone changed the file permissions
It turns out the whole thing was caused when someone from Technical Support decided to change the permissions on the deliveries.txt file, making it read-only. When the system tried to write deliveries into ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access