error code

Mark McEahern marklists at mceahern.com
Wed Jul 24 11:04:05 EDT 2002


> I want to get the code of an error .
>
> how can I do that ?
>
> With "sys.exc_value" and "sys.exc_type" I have a String .
> But I want a Integer

This probably isn't what you want, but given the vagueness of your question,
how the heck would I know that?  <wink>

class MySpecialError(Exception):

  code = 100

try:
	raise MySpecialError
except Exception, e:
	if hasattr(e, "code"):
		print "Code: %d" % e.code

// mark

-





More information about the Python-list mailing list