Re: [Cppcms-users] How to catch CPPDB errors
Brought to you by:
artyom-beilis
|
From: Marcel H. <ke...@co...> - 2013-01-24 11:26:22
|
Am 23.01.2013 14:50, schrieb Artyom Beilis: > I would suggest in general... > > Not get into situations where you can get a error, or at least if you > expect a error catch it. Think of registration. A Username should be unique and a email adrress should be unique too. I will not check this, because IMO this is a task for the database. > > What kind of errors can happen: > > 1. Constrain violation: > * Check it before from a transaction assuming isolation > * Catch at specific point - assume that the error is constraint > violation. > 2. Deadlock - due to colliding statements - not much to do. Or let 500 > response to happen or catch a cppdb error at the root of you > app hierarchy main and say (oops) > 3. Connection errors or other stuff - 500 is more than reasonable - or > do it what you did in 2 > > Now about specific errors. > > Probably it would be good idea to derive several sub exceptions like: > > cppdb::constraint_error > cppdb::deadlock_error > cppdb::connection_error Could be good, but there are over 100 errors that can happen while you execute a statement. But i will have a look and see what i can do. > > Similarly to the current > set: http://cppcms.com/sql/cppdb/classcppdb_1_1cppdb__error.html > > Maybe some more I can't think about them right now. > > But this requires some code writing and what is even more important - > updating each backend and probably > the most hard would be ODBC. > > Any volunteers? > > > Artyom Beilis Marcel |