Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

user managed error processing

Status
Not open for further replies.

hammy86

Programmer
Oct 4, 2006
6
0
0
US
Hello,
I have inherited some Python code and I am not a Python programmer. I am looking for a simple way to trap an error so I can gracefully manage the error. Right now it just puts the error on the screen. I think I need to use

import cgitb; cgitb.enable()

somehow, but I can not figure out how. Any hints?

 
this works provided your Python code is a CGI script
I usually place this line at the start of the code
before any other imports, e.g.,
Code:
#!/usr/bin/python
"""this is my CGI script
"""
import cgitb; cgitb.enable()
import MySQLdb

# rest of code here

what the cgitb.enable() call does though is output a
formatted traceback to stdout
(which in the case of a CGI script is the client's browser)
 
Makes sense - so any idea how I stop it from going to the browser?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top