[Tutor] Checking for custom error codes

Alan Gauld alan.gauld at btinternet.com
Tue Aug 7 19:25:51 CEST 2007

"wormwood_3" <wormwood_3 at yahoo.com> wrote

> Recently I was trying to do a "try: X except Y: Z" statement, 
> checking for a custom error code

>        for potdomain in self.potdomains:
>            try:
>                who.whois(potdomain)
>                self.availdomains.append(potdomain)
>            except 'NoSuchDomain':
>                pass
>            self.totalchecked+=1
> got a warning that throwing a string exception is deprecated,
> but the check did not work anyway.

So what did happen? Your code simply ignores the error so, for it not
to work, I assume you are still getting an error report and traceback?
If so what does it say?

Python error messages may look arcane to start with but they usually
contain enough information to identify a problem without any further
debugging - but only if we can see them! :-)


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list