Print recent CGI error

MRAB python at mrabarnett.plus.com
Sat Dec 4 15:01:10 EST 2010


On 04/12/2010 18:33, Gnarlodious wrote:
> I have a serious error that causes the process to crash. Apache
> refuses to log the error and it only happens on the server, not on the
> dev machine. Problem is, I can't figure out how to get the most recent
> error. I can find all sorts of pages telling how to print a specific
> error, but how to get an unknown error:
>
> Here is where I am:
>
> NowCookie.load(savedCookie)
> try:
>      savedCookie=NowCookie['Sectrum'].value  # PROCESS CRASHES HERE
> except:
>      print("Content-type:text/html\n\n")
>      print("???")  # PRINT WHATEVER ERROR OCCURRED
>      quit()
>
> There must be something so simple I am missing...
>
> This is Python 3.
>
You could try something like:

import traceback

NowCookie.load(savedCookie)
try:
     savedCookie=NowCookie['Sectrum'].value  # PROCESS CRASHES HERE
except:
     print("Content-type:text/html\n\n")
     traceback.print_exception(*sys.exc_info())  # PRINT WHATEVER ERROR 
OCCURRED
     quit()



More information about the Python-list mailing list