Graceful failures

Jacob H jacobsmail at postmark.net
Mon Dec 29 17:14:43 EST 2003


Hello all,

I'm nearing the completion of my first graphical console game and my
thoughts have turned to the subject of gracefully handling runtime
errors. During development I like to not handle exceptions, so that
program execution will halt and I can immediately read the traceback
to see what's up. Once the bugs are more or less worked out, I have a
system ready wherein any exceptions are caught and an attempt is made
to write the traceback object to a log file. This system suits me for
the upcoming testing phase - if my beta testers do anything to make
the game crash, I can read about the error and its causes in the log
later.

But what about the eventual production version that I distribute to
the public? My current understanding is that there's always a chance a
computer program can fail in some way at runtime, disk access being an
example. Suppose the startup code for my game fails to load one of the
images from disk. I can't think of any reasonable way to rescue
things, and under such conditions I would prefer that the program
gracefully exits. The aforementioned traceback logging is fine for me
as the developer, but useless to the end user of the production
version. So - I'm real curious - what are the canonical ways that a
computer application should gracefully fail?

I'm somewhat reluctant to write a bunch of code for pretty windows
that pop up with some message to the effect of, "internal error, game
exiting." My main reservation here is it doesn't seem it can be done
cross platform, and since my game is in a graphical console there's no
place for stdout to write. However, if this is the best way to go
about error handling, I'm willing to write the code. And I would
appreciate advice about how to handle the cross platform problem. :)

Thanks in advance for any help!

Jake




More information about the Python-list mailing list