Trapping Exceptions

Steve Holden sholden at
Wed Nov 8 14:14:12 CET 2000

Dale Strickland-Clark wrote:
> I'm having a bit of trouble trapping an exception raised by one of my
> own classes.
> The code trying to trap the exception is:
> try:
>         if type(fld) == types.InstanceType:
>                 parts.append(RenderObj.Data(fld.Heading,
> fld.Description))
>         else:
>                 parts.append(RenderObj.Data(self.FieldHdr(f), fld))
> except Hell:
>         pass
> The requests for the attributes of fld may raise this exception:
> if self.RS is None:
>         raise Hell(21, (key, self.__class__.__name__))
> return self.FormatField(key, self.RS.Fields(key).value)
> However, the exception isn't getting trapped. Now, I suspect it's
> something to do with the Hell object but I can't figure out what. My
> understanding of the docs and experiments with simpler cases suggests
> that this should work
> Any help appreciated.

Maybe you could show us the definition of Hell (and don't say a place
where we are all forced to program in P**l :-) -- I assume you are
subclassing exceptions.Exception?

Helping people meet their information needs with training and technology.
703 967 0887      sholden at

More information about the Python-list mailing list