[Tutor] Checking for custom error codes

wormwood_3 wormwood_3 at yahoo.com
Tue Aug 7 16:47:38 CEST 2007

Hi all,

I am new to Python programming and this list, looks like a great place so far!

Recently I was trying to do a "try: X except Y: Z" statement, checking for a custom error code that the rwhois.py module throws. Some details on the exercise and the full code can be found on this post ( http://assistedsilicon.blogspot.com/2007/08/fun-with-python-domainspotter.html ). So, here is what I tried:

        for potdomain in self.potdomains:
            except 'NoSuchDomain':
If you need more context, the whole program is here ( http://assistedsilicon.blogspot.com/2007/08/fun-with-python-domainspotter.html#code ). I first tried simply "except NoSuchDomain", since that was what I saw rwhois throw when I sent it a domain that was not registered. That did not work, so I quoted it. I got a warning that throwing a string exception is deprecated, but the check did not work anyway. Am I trying to check for this custom error wrongly? How should it be done?

Thanks for any assistance!


More information about the Tutor mailing list