summaryrefslogtreecommitdiff
path: root/libodbcpp/error.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2008-11-13 14:45:11 +0000
committerrandomdan <randomdan@localhost>2008-11-13 14:45:11 +0000
commitefd292508070835781a0d92448a3661279dfd307 (patch)
tree0d2592bacfdb0cd159ebc5780dd69f86cc893af0 /libodbcpp/error.cpp
parentFix the C++ template errors (diff)
downloadlibdbpp-odbc-efd292508070835781a0d92448a3661279dfd307.tar.bz2
libdbpp-odbc-efd292508070835781a0d92448a3661279dfd307.tar.xz
libdbpp-odbc-efd292508070835781a0d92448a3661279dfd307.zip
Lots of little fixes
Diffstat (limited to 'libodbcpp/error.cpp')
-rw-r--r--libodbcpp/error.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/libodbcpp/error.cpp b/libodbcpp/error.cpp
index c7f16c7..5497f4d 100644
--- a/libodbcpp/error.cpp
+++ b/libodbcpp/error.cpp
@@ -6,7 +6,7 @@
static
void
-odbc_verror(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const * actionfmt, va_list ap)
+odbc_verror(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const * actionfmt, va_list ap, char ** msg)
{
SQLCHAR sqlstatus[6];
SQLINTEGER sqlerr;
@@ -20,16 +20,22 @@ odbc_verror(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const *
switch (rc) {
case SQL_SUCCESS:
case SQL_SUCCESS_WITH_INFO:
+ asprintf(msg, "%d: %ld: %5.5s: \"%s\" while attempting to %s",
+ err, sqlerr, sqlstatus, sqlerrmsg, action);
syslog(LOG_WARNING, "%s: %d: %ld: %5.5s: \"%s\" while attempting to %s",
__FUNCTION__, err, sqlerr, sqlstatus, sqlerrmsg, action);
break;
case SQL_INVALID_HANDLE:
+ asprintf(msg, "(%d) Invalid handle passed into function trying to %s.",
+ err, action);
syslog(LOG_ERR, "%s: (%d) Invalid handle passed into function trying to %s.",
__FUNCTION__, err, action);
break;
case SQL_NO_DATA:
+ asprintf(msg, "(%d) No error data available for record trying to %s.",
+ err, action);
syslog(LOG_ERR, "%s: (%d) No error data available for record trying to %s.",
__FUNCTION__, err, action);
break;
@@ -47,8 +53,8 @@ ODBC::Error::Error(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char c
va_list ap;
va_start(ap, action);
- odbc_verror(err, handletype, handle, action, ap);
- va_end(ap);
+ odbc_verror(err, handletype, handle, action, ap, &msg);
+ va_end(ap);
}
ODBC::Error::Error(char const * action, ...)
@@ -56,7 +62,19 @@ ODBC::Error::Error(char const * action, ...)
va_list ap;
va_start(ap, action);
- vsyslog(LOG_ERR, action, ap);
+ vsyslog(LOG_ERR, action, ap);
+ vasprintf(&msg, action, ap);
va_end(ap);
}
+ODBC::Error::~Error() throw()
+{
+ free(msg);
+}
+
+const char *
+ODBC::Error::what() const throw()
+{
+ return msg;
+}
+