[Tutor] Error-handling for a large modular program

Shrutarshi Basu technorapture at gmail.com
Fri Jun 6 06:07:09 CEST 2008


I'm currently working on a research project where we'll be developing
a moderately complex piece of software. We're designing with
extensibility in mind. One of the problems I can see right now is that
our program can potentially create a large number of very different
errors, some fatal, some not. Part of this is because the front end of
the program is essentially a parser for a moderately complex
configuration language, which means that there are a variety of
syntax/semantics errors possible. Since the project is in the
beginning stages, I've only implemented basic error handling through a
number of try/except blocks and if/elses. However I feel that the code
might become increasingly inelegant if I keep adding a try/except for
every possible error (and breaking up the code to make it be a
specific as possible about the errors). Is there some more generic,
high-level approach I could use?
One approach I have thought of is creating a error handler class where
each class method corresponds to a particular error. An instance of
this class would be created at the start of the program and each error
would run a method in the class. This would allow us to have elaborate
error handling code, without cluttering the actual working code. We'd
still need try/catch blocks, but the catches wouldn't be anything more
than method calls. Since we have 3-4 people, each working on a
different part of the program, we could each add to this error handler
as needed.
Since this is my first real world application that I'm writing as a
team, I have no idea how error handling is actually done in large
applications. So any suggestions would be appreciated.
Thanks for your help,
Shrutarshi

-- 
The ByteBaker :
http://www.bytebaker.com


More information about the Tutor mailing list