Tim Littlemore wrote:
Jeremy Jones wrote:
Tim Littlemore wrote:
Kevin Dangoor wrote:
I believe that IntegrityError comes from your database driver. You'll
likely have to import it from there.
Kevin
Thanks Kevin,
That was it! Fixed it by adding this to controllers.py:
from _mysql_exceptions import *
Cheers,
Tim
I asked Ian about this some time back and you can do it more
generically like this:
MyClass._connection.module.IntegrityError
This was about 3 months back and I haven't tried it since then.
- jmj
Hi Jeremy,
Would that be what I'd put in my 'except' line? E.g.:
except MyClass._connection.module.IntegrityError:
Cheers,
Tim
That should be it. I just checked and my "Product" class has a
Product._connection.module.IntegrityError. It's just a db independent
way of getting at the integrity error. Otherwise you'd have
try:
do_some_db_operation()
except mysql.IntegrityError:
handle_exception()
except postgres.IntegrityError:
handle_exception()
except etc....
- jmj