How do I get info on an exception ?

Cameron Laird claird at lairds.com
Tue Jul 22 12:44:04 EDT 2003


Raymond Hettinger <python at rcn.com> wrote:
>> >You could catch it with:
>> >
>> >            except socket.herror, inst:
>> >                  print inst.args
>> >
>> >or more broadly with:
>> >
>> >             except socket.error, (errno, string_message):
>> >                   print code, message
>> >
>> >
>> >> More importantly, where is the answer documented that I should
>> >> have looked?
>> >
>> >The list of possible socket exceptions is in the docs for sockets.
>> >It also describes the (errno, string) return tuple value of inst.args.
>> .
>> .
>> .
>> True.
>>
>> But unsatisfying--at least to me.
>
>Submit a patch.
			.
			.
			.
I deserved that.

There was more to my post, of course.  Part of what I was trying to
express is that exception interfaces are almost always relegated to
a footnote, with only a generalized description, even in the frequent
case that a method's exceptions are more complicated than its invoca-
tions.

Rather than tilt at the collection of all such windmills, I want to
first understand better why this is, and what response is appropriate.
To summarize:  I don't know what patch is the right one.  I also
thought it only fair to warn Mr. July that things are indeed more dif-
ficult than we were explaining, even though I didn't feel up to 
detailing the difficulties.

So, Raymond, do you have general guidelines for how you think excep-
tions should be documented?
-- 

Cameron Laird <Cameron at Lairds.com>
Business:  http://www.Phaseit.net
Personal:  http://phaseit.net/claird/home.html




More information about the Python-list mailing list