Hi Fulvio,

I often use this try except to find out about what type of errors might
happen in my code:
I use it when I really don't know what might happen.
try:
    # do something
except:
    print "Unexpected error:", sys.exc_info()[0]
    continue

once it catches an error, just take a good look at the error message
and you'll be able to extend the try except like this:

try:
    # do something
except KeyError:
    print "this is a KeyError"
    continue
except TypeError:
    print "this is a TypeError"
    continue
except:
    print "Unexpected error:", sys.exc_info()[0]
    os.system("pause")
    continue

Fulvio wrote:
> ***********************
> Your mail has been scanned by InterScan MSS.
> ***********************
>
>
> Hello there,
>
> Simple question : how do I manage errors by the use "try/except" clause.
> Example:
> If I'd like to catch error coming from a function call that's using IMAP4
> class, which error may raise such class?
> In other words I've doubts about which error object I should put after
> the "except" statement in order to trap the wanted error.
>
> Is there, somehow, the way to list the errors from a class or function, prior
> digging into the source?
> 
> F

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to