Exception holes, again.

F. GEIGER fgeiger at datec.at
Mon Nov 5 21:28:42 CET 2001


I had the same problem. This is what Mark Hammond and David Bolen answered
to me (cut & pasted from my browser; you can find the whole thread if you
search for "Geiger pywintypes" in groups.google.com:
http://groups.google.com/groups?q=geiger+pywintypes&hl=de&btnG=Google-Suche)
:

--------
Von:Mark Hammond (MarkH at ActiveState.com)Betrifft:Re: Want to catch
pywintypes.api_error Newsgroups:comp.lang.pythonView this article only
Datum:2001-03-13 05:27:15 PST Franz GEIGER wrote:

> When I start win32api.FindFiles(filespec) with a non-existing filespec it
> throws an exception of class pywintypes.api_error. But a "except
> pywintypes.api_error, e:" does not work. Using "except Exception, e:" does
> the job, because Exception is the base class. But how can I catch
api_error?
> What do I miss?
>

win32api.error

Mark.Message 3 in thread Von:Franz GEIGER (fgeiger at datec.at)Betrifft:Re:
Want to catch pywintypes.api_error Newsgroups:comp.lang.pythonView this
article only Datum:2001-03-13 09:38:19 PST  Thank you, Mark!

How could I have figured out this by myself? I did a text search for
api_error over my ActivePython distribution, w/o success. Is it burrie din
those pyd-files?

Regards
Franz


"Mark Hammond" <MarkH at ActiveState.com> wrote in message
news:3AAE208D.4010103 at ActiveState.com...
> Franz GEIGER wrote:
>
> > When I start win32api.FindFiles(filespec) with a non-existing filespec
it
> > throws an exception of class pywintypes.api_error. But a "except
> > pywintypes.api_error, e:" does not work. Using "except Exception, e:"
does
> > the job, because Exception is the base class. But how can I catch
api_error?
> > What do I miss?
> >
>
> win32api.error
>
> Mark.
>Message 4 in thread Von:David Bolen (db3l at fitlinxx.com)Betrifft:Re: Want to
catch pywintypes.api_error Newsgroups:comp.lang.pythonView this article only
Datum:2001-03-13 17:54:06 PST  "Franz GEIGER" <fgeiger at datec.at> writes:

> How could I have figured out this by myself? I did a text search for
> api_error over my ActivePython distribution, w/o success. Is it burrie din
> those pyd-files?

I'm not sure if it's explicitly documented, but one good way is to do
a dir() of the module at hand - you'll find an "error" object in both
pywintypes and the individual modules such as win32api.

It is a bit confusing that the internal class is called api_error (and
that's how the instance objects display themselves) but the actual
instance is called error.  But having an "error" object in a module
for exceptions is reasonably common, so a good thing to check for.

--
-- David
--
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/ --
------


"Dale Strickland-Clark" <dale at riverhall.NOTHANKS.co.uk> schrieb im
Newsbeitrag news:k808uto6v8g6f2ilnfvdv1ondah38lslif at 4ax.com...
> On a related subject to the earlier exceptions wart thread.
>
> I want to trap the specific 'api_error' exception raised by win32api.
>
> I can't find where that exception is defined so how do I catch it?
>
> I have searched the whole Python installation for the string
> 'api_error' but it isn't there.
> --
> Dale Strickland-Clark
> Riverhall Systems Ltd

--------





More information about the Python-list mailing list