Error Handling
Victor Subervi
victorsubervi at gmail.com
Thu Apr 17 15:19:12 EDT 2008
Hi;
I have the following code:
try:
cursor.execute(sql)
print '¡Exito en introducir!<br />'
print '<i>Esta página va a regresar a la página principal del carrito
de compras en 10 segundos.</i>'
except IntegrityError:
print 'Lo siento, pero el ID que entraste está usado actualmente por
otra entrada. Favor de dar para atráz y escojer otro número.'
except OperationalError:
print 'Lo siento, pero has añadido un carácter extraño a un número (o
en "ID", "precio", "recámaras" o "baños". Favor de dar para atráz y escojer
otro número.'
except:
print 'Lo siento, pero hay un error. Favor de dar para atráz y
averiguar donde está el error, y reintentar.'
When I enter and ID that is not a number, it should trigger the
IntegrityError. Instead, I get this in the error log:
[Thu Apr 17 12:06:37 2008] [error] [client 190.166.0.245] PythonHandler
mod_python.cgihandler: NameError: global name 'IntegrityError' is not
defined, referer: http://livestocksling.com/bre/iud.py
When I enter a non-digit in a float, I should get an OperationalError.
Instead, I get more garbage:
[Thu Apr 17 12:10:38 2008] [error] [client 190.166.0.245] PythonHandler
mod_python.cgihandler: NameError: global name 'OperationalError' is not
defined, referer: http://livestocksling.com/bre/iud.py
What do?
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080417/0fc5b1a0/attachment.html>
More information about the Python-list
mailing list