From 52841daec985e04bff77ee6eb1d70af0238e0eae Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Thu, 19 Sep 2013 19:50:31 +0100 Subject: Throw sane exception when wrong type used in PreparedStatement. Change-Id: Ie9577ed021930c56f3270aa30306d89365c1b3b1 --- connectivity/source/drivers/firebird/PreparedStatement.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index d1261d441a6a..574bc06bb810 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -222,12 +222,13 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex, case SQL_TEXT: memcpy(pVar->sqldata, str.getStr(), str.getLength()); // Fill remainder with spaces - // TODO: would 0 be better here for filling? memset(pVar->sqldata + str.getLength(), ' ', pVar->sqllen - str.getLength()); break; default: - // TODO: sane error message - throw SQLException(); + ::dbtools::throwSQLException( + "Incorrect type for setString", + ::dbtools::SQL_INVALID_SQL_DATA_TYPE, + *this); } } @@ -341,7 +342,12 @@ void OPreparedStatement::setValue(sal_Int32 nIndex, T& nValue, ISC_SHORT nType) XSQLVAR* pVar = m_pInSqlda->sqlvar + (nIndex - 1); if ((pVar->sqltype & ~1) != nType) - throw SQLException(); // TODO: cast instead? + { + ::dbtools::throwSQLException( + "Incorrect type for setString", + ::dbtools::SQL_INVALID_SQL_DATA_TYPE, + *this); + } memcpy(pVar->sqldata, &nValue, sizeof(nValue)); } -- cgit