summaryrefslogtreecommitdiff
path: root/libodbcpp/error.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libodbcpp/error.cpp')
-rw-r--r--libodbcpp/error.cpp31
1 files changed, 7 insertions, 24 deletions
diff --git a/libodbcpp/error.cpp b/libodbcpp/error.cpp
index 51b90c6..e971714 100644
--- a/libodbcpp/error.cpp
+++ b/libodbcpp/error.cpp
@@ -3,23 +3,17 @@
#include <syslog.h>
#include <malloc.h>
#include <time.h>
+#include <string.h>
#include "error.h"
static
void
-odbc_verror(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const * actionfmt, va_list ap, char ** msg)
+odbc_verror(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const * action, char ** msg)
{
SQLCHAR sqlstatus[6];
SQLINTEGER sqlerr;
SQLCHAR sqlerrmsg[12800];
- char * action;
- if (vasprintf(&action, actionfmt, ap) < 0) {
- syslog(LOG_WARNING, "%s: %d: %ld: %5.5s: \"%s\" : failed to malloc for vasprintf",
- __FUNCTION__, err, sqlerr, sqlstatus, sqlerrmsg);
- return;
- }
-
SQLRETURN rc = SQLGetDiagRec(handletype, handle, 1, sqlstatus, &sqlerr, sqlerrmsg,
sizeof(sqlerrmsg), NULL);
switch (rc) {
@@ -62,28 +56,17 @@ odbc_verror(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const *
syslog(LOG_ERR, "%s: Unexpected error!!", __FUNCTION__);
break;
}
- free(action);
}
-ODBC::Error::Error(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const * action, ...)
+ODBC::Error::Error(RETCODE err, SQLSMALLINT handletype, SQLHANDLE handle, char const * action)
{
- va_list ap;
-
- va_start(ap, action);
- odbc_verror(err, handletype, handle, action, ap, &msg);
- va_end(ap);
+ odbc_verror(err, handletype, handle, action, &msg);
}
-ODBC::Error::Error(char const * action, ...)
+ODBC::Error::Error(char const * action)
{
- va_list ap;
-
- va_start(ap, action);
- vsyslog(LOG_ERR, action, ap);
- if (vasprintf(&msg, action, ap) < 1) {
- msg = NULL;
- }
- va_end(ap);
+ syslog(LOG_ERR, "%s", action);
+ msg = strdup(action);
}
ODBC::Error::Error(char * m) : msg(m)