[Cppcms-users] How to catch CPPDB errors
Brought to you by:
artyom-beilis
|
From: Marcel H. <ke...@co...> - 2013-01-23 12:36:10
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi everyone,
I'd like to know the "correct" way of handling errors in cppdb
statements.
If I do something like this:
"INSERT INTO ...." << cppdb::exec;
and there will be an error, a 500 respond will be given to the client.
Not that nice.
Next try was to catch the exception:
try {
"INSERT INTO ...." << cppdb::exec;
} catch(cppdb::cppdb_error const &e) {
//what can we do here?
}
Nice try, but cppdb_error has only the method what() and what gives me
back a char* with the error description. But there could be more than
one error in that query. That's why there are error codes. But
unfortunately every sql provider has different error codes.
Another problem with cppdb error is that the message will be
localized, so you cannot parse it.
So... what is the right way to do this?
Regards
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBAgAGBQJQ/9kvAAoJEIROXYQnkAHpZPEQAJwW8mdI96vYANq+9Akaf65C
ykNGxrygD87HMizKQ0EPhH7qS1KuvvjYHL1z+eryEOHcILsRfvbnaHRsCAGlq6Lk
hMNrCzKeMQpcKkkYqBN4YGHzXMA+slsnQVNRQtpi7QrB3Veeg5M4Unm2tYZJenUH
HNRM1rIqqih0R2swYTZa9HXVqNkZyC9ssPo5YUtd5KK/qftv5mb5fbUgh5TIoYh6
2GqTEZJYqamMeLnUjTGkZ2EOnz07KGPlW0/PBrhYdeTIxesHIKQC3flDKvWPX8cL
CA0N4uTiAg7EF6L8CJ+CsmsEBe1wa6TSncShcqmqImM0K1ZBmFG/e1AThC80biW2
u/0A2pBfMqxdJFXDBg+/CS3ewu5A9UFX79bT0EfiZm3cLwsrLZ0bYvsC/c/aAG2v
7UfENgldy+79Rk4nUS6ZQxKbMJRmOxznsMrCrAPZl4es1VcNpfm5Drsvm6VV4sCs
0KBqN11o8rZMfLj8fWc139PwJjKGqcGW8xRjykhpWpDFwennygTBz0Hqn0BJf9Of
8nENk0bPoORGtqcgR2hf5Yp4HrM7QBP2+/hTdWNmrur+pr6tnP08U13hcBZtNlur
swTucg5WVp1GjHAmf9BZozEHhKZAY7sJZvWAZQJrbcfdYywTO9y6hERj/5sS2J2P
EmlSmccnwf7Slmw7+5n6
=CiN2
-----END PGP SIGNATURE-----
|