[Tutor] error trap
kirk Bailey
idiot1@netzero.net
Fri, 18 Jan 2002 03:25:38 -0500
Danny Yoo wrote:
>
> On Fri, 18 Jan 2002, kirk Bailey wrote:
>
> > ok, built a pretty blunt weapon to handle errors.
> >
> > IN TLpost.py;
> > for to_addr in members : # for each address in
> > 'listnamemembers',
> > # print "to_addr: ", to_addr
> > # print "from_addr: ", from_addr
> > # print "msg=" + CRLF, msg
> > try:
> > server.sendmail(from_addr, to_addr, msg) # 400 send envlope and msg!
> > except:
> > print "Bad address='"+to_addr+"'"
>
> It might be good to also print out the error message that the system
> itself gives. Every exception that gets thrown brings with it a useful
> error message for debugging purposes. So:
>
> ###
> try:
> server.sendmail(from_addr, to_addr, msg)
> except Exception, e:
^^^^^^^^^ ^ ??? more data please?
> print "Bad address='"+to_addr+"'"
> print "exception message:", e <-- this must be ther actual error reported?
> ###
>
> is more informative, if a bit uglier. Still, it'll help if anything weird
> happens.
Should I install a wierdness magnet? Maybe a prayer wheel to obtain
blessings?
To perdition with cosmetics, just help me understand it!
(we can pretty up the listing later...)
> > Testing with a known bad address in the list, it comes up with an
> > error print, and finishes the job.
>
> The reason why we still want to print out the exception is as a worst-case
> thing: what if there were some other way to make server.sendmail() die
> other than a bad 'to_addr'? There probably isn't a way, but let's make
> certain that, in the case that we've overlooked something, we'll still get
> useful information from the error.
Sounds like a plan to me, just tell me a little more bout this
statement I threw carrots at.
(bad pun I know.)
--
-Respectfully,
-Kirk D Bailey
Consulting Loose Cannon
end
www.howlermonkey.net highprimate@howlermonkey.net
www.sacredelectron.org idiot1@netzero.net
www.tinylist.org grumpy@tinylist.org
----------------------------------------------------
Sign Up for NetZero Platinum Today
Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97