views:

21

answers:

2

I've just found myself in situation where I needed to handle exception I'll probably never get, so out of curiosity, let's do a small poll.

  1. Do you validate the presence of resources in your programs? I mean, those resources which are installed with your program, like icons, images and similar. Generally, if those are missing, either your install didn't do its job, or the user randomly deleted files in your app.

  2. If you do validate the presence, what do you do when the files are not there?

Of course, for web apps, you'll have nice 404 page or broken link, but what about the rest? Fail early, yes, but leave handling failures to your compiler, or what?

A: 

In Python, many folks rely on simple exception handling for this kind of thing. We might wrap an application in a Big-Old-Try-Block that reports "serious problems" for unhandleable exceptions like this and tries to clean up and exit gracefully.

It's hardly worth checking deeply in advance.

If it's even possible for the user to get to some super delicate and precious part of the application and the app dies undoing hours (or years) of work, then you should rethink that use case to create a more robust scenario where a crash is not so destructive.

S.Lott
A: 
Longpoke