From: Andy T. <an...@ha...> - 2005-09-18 04:04:13
|
bra...@om... wrote: > > While looking at the PythonCard source code, I noticed a couple of > "except:" statements > lacking specific qualifiers. So I did a search of all the source code > and found that that's > really the predominant practice in PythonCard. > > I don't have much experience handling exceptions from wx, but even if we > have no > idea what kind of exception we're getting back, we can at least trap for > the general > Exception object, and maybe print something about it. > > As in, > > try: > #something > except Exception, thisErr: > print 'Found an error here:', thisErr > > > In cases where we know the specific error to expect, we could actually > trap for it. > For instance, in model.py, the very first try block uses assertions to > make sure > a minimum version of Python and wx are available. We could trap for > AssertionError. > > * > Brad Allen* > IT Desktop Support > _ > __b...@om..._ <mailto:bra...@om...> Indeed, and I've made a start and checked in a number of changes today. If anybody else wants to join in I hereby declare September 'remove catch all exceptions' month. The only point to add to Brad's is that I've found one instance (in sound.py) of an explicit 'raise' without a named exception. I added a custom exception (inheriting from the standard Exception class) and tested for it in the sample application code. If anyone spots any 'raise' statements elsewhere in the code I recommend doing the same. Regards, Andy -- -------------------------------------------------------------------------------- From the desk of Andrew J Todd esq - http://www.halfcooked.com/ |