summaryrefslogtreecommitdiff
path: root/odb/mssql/error.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-20 13:30:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-20 13:30:43 +0200
commit16283f61ddd0525b08e615fac6148f544973ac82 (patch)
tree04d2a2116ea9c6ee87bf441ca22df6e7f7e6572b /odb/mssql/error.cxx
parent0362bba70741404fb5dca7f0bb7aa4c484f307cc (diff)
Handle error conditions that are indicated via return code
Diffstat (limited to 'odb/mssql/error.cxx')
-rw-r--r--odb/mssql/error.cxx48
1 files changed, 40 insertions, 8 deletions
diff --git a/odb/mssql/error.cxx b/odb/mssql/error.cxx
index b405db7..b659bd6 100644
--- a/odb/mssql/error.cxx
+++ b/odb/mssql/error.cxx
@@ -17,10 +17,40 @@ namespace odb
namespace mssql
{
static void
- translate_error (SQLHANDLE h, SQLSMALLINT htype, connection* conn)
+ translate_error (SQLRETURN r,
+ SQLHANDLE h,
+ SQLSMALLINT htype,
+ connection* conn)
{
- SQLRETURN r;
+ // First see if we have one of the errors indicated via the
+ // return error code.
+ //
+ switch (r)
+ {
+ case SQL_STILL_EXECUTING:
+ {
+ throw database_exception (0, "?????", "statement still executing");
+ break;
+ }
+ case SQL_NEED_DATA:
+ case SQL_NO_DATA:
+#if ODBCVER >= 0x0380
+ case SQL_PARAM_DATA_AVAILABLE:
+#endif
+ {
+ throw database_exception (
+ 0, "?????", "unhandled SQL_*_DATA condition");
+ break;
+ }
+ case SQL_INVALID_HANDLE:
+ {
+ throw database_exception (0, "?????", "invalid handle");
+ break;
+ }
+ }
+ // Otherwise the diagnostics is stored in the handle.
+ //
char sqlstate[SQL_SQLSTATE_SIZE + 1];
SQLINTEGER native_code; // Will be 0 if no natve code.
char msg[512]; // Will be truncated if doesn't fit.
@@ -161,21 +191,23 @@ namespace odb
}
void
- translate_error (connection& c)
+ translate_error (SQLRETURN r, connection& c)
{
- translate_error (c.handle (), SQL_HANDLE_DBC, &c);
+ translate_error (r, c.handle (), SQL_HANDLE_DBC, &c);
}
void
- translate_error (connection& c, const auto_handle<SQL_HANDLE_STMT>& h)
+ translate_error (SQLRETURN r,
+ connection& c,
+ const auto_handle<SQL_HANDLE_STMT>& h)
{
- translate_error (h, SQL_HANDLE_STMT, &c);
+ translate_error (r, h, SQL_HANDLE_STMT, &c);
}
void
- translate_error (SQLHANDLE h, SQLSMALLINT htype)
+ translate_error (SQLRETURN r, SQLHANDLE h, SQLSMALLINT htype)
{
- translate_error (h, htype, 0);
+ translate_error (r, h, htype, 0);
}
}
}