Depending on the situation it may also be necessary to do: try: .... except db._adapter.driver.IntegrityError as e: db.rollback() # or db.commit() return str(e)
On Saturday, 11 January 2014 09:17:33 UTC-6, Anthony wrote: > > It depends on how the particular exception class is implemented. In > general, if you do str(error), you get the error message. I think in most > exception classes, error.args[0] is also typically the error message. This > is a general Python issue and not specific to web2py. > > try: > .... > except db._adapter.driver.IntegrityError as e: > return str(e) > > Anthony > > On Saturday, January 11, 2014 1:55:30 AM UTC-5, software.ted wrote: >> >> Hi Anthony! >> >> Those gems we need to know!!!, since i have to extract undocumented >> details on this list, I would like to find out how i can then get system >> generated messages cause there are many integrity error >> descriptions...instead of me having one message like this: >> >> try: >> ... >> except db._adapter.driver.IntegrityError: >> err_msg = "Duplicate record in database" >> >> I would like to have a situation were i can get system messages of the >> specific integrity error enountered: >> >> try: >> ... >> except db._adapter.driver.IntegrityError: >> err_msg = db.[some object].errorMessage >> >> >> Any pointers? >> >> >> On Sat, Jan 11, 2014 at 8:11 AM, Anthony <abas...@gmail.com> wrote: >> >>> Another one of our great undocumented gems. :-) >>> >>> -- >>> Resources: >>> - http://web2py.com >>> - http://web2py.com/book (Documentation) >>> - http://github.com/web2py/web2py (Source code) >>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "web2py-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to web2py+un...@googlegroups.com. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> >> >> -- >> >> ....................................................................................... >> Teddy Lubasi Nyambe >> Opensource Zambia >> Lusaka, ZAMBIA >> >> Cell: +260 97 7760473 >> website: http://www.opensource.org.zm >> >> ~/ >> Human Knowledge belongs to the world! - AntiTrust >> >> Man is a tool-using animal. Without tools he is nothing, with tools he is >> all - Thomas Carlyle 1795-1881 >> >> /~ >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.