[PythonCAD] Handling exceptions in sendMessage() calls

Art Haas ahaas at airmail.net
Wed Jun 15 18:29:09 CEST 2005


Last month I send an e-mail to the list about the problem of dealing with
exceptions during sendMessage() calls. After trying various ideas and
seeing flaws in them, and thinking more about the problem, my latest
conclusion is that the exceptions raised during sendMessage() calls
cannot be handled given the current design of the messaging system. What
I'm looking at doing is utilizing the traceback module to print out the
stack trace but not raise the exception after that so things continue
going along. In the 'message.py' file I've added a try/except clause
looking something like this:

		method(self, *args)

The lack of a 'raise' statement in the except block means the exception
is "handled" there, although in reality all that is done is print out
where things went boom. I'm now trying to decide what can or should be
done to indicate that the drawing is in an inconsistent state. Depending
on where the exception happened, the drawing itself is fine, as would be
the case if a draw() operation failed. On the other hand, things could
be really screwed up. I'm not sure what to do just yet. Suggestions?

Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822

More information about the PythonCAD mailing list