[Tutor] Trapping Interpreter errors as a string
Mon, 26 Feb 2001 18:33:36 -0900
Am looking for a way to trap python errors as a string.
A quick example would be like the disarm function in the rebol language.
To be more specific:
Let's say I had a simple cgi program to first sent the the mime-type
print "Content-type: text/html\n"
then I do something dumb, like
integer = string.atoi("duh")
Guido will then say:
Traceback (innermost last):
File "<stdin>", line 1, in ?
ValueError: invalid literal for atoi(): duh
To reduce this inquiry:
1)Can that error message be returned to the user as a string.
2)Is there a specific numeric error code attached to the error message.
i.e. ValueError = ?
Then the programmer could gracefully complete the output form with
the error message within it.
I hope I being clear here.
"Of all manifestations of power,
restraint impresses the most."