Date: Tuesday, March 7, 2006 @ 12:17:44
Author: gilles
Path: /cvsroot/carob/carob
Modified: include/CarobException.hpp (1.37 -> 1.38)
include/DriverResultSet.hpp (1.32 -> 1.33)
src/DriverResultSet.cpp (1.44 -> 1.45)
Introduced ConversionException, to be used when a value cannot be converted to
another type, typically in DriverResultSet::GetAsXXX
-----------------------------+
include/CarobException.hpp | 14 ++++++++++++++
include/DriverResultSet.hpp | 18 ++++++++++++------
src/DriverResultSet.cpp | 13 ++++++++-----
3 files changed, 34 insertions(+), 11 deletions(-)
Index: carob/include/CarobException.hpp
diff -u carob/include/CarobException.hpp:1.37
carob/include/CarobException.hpp:1.38
--- carob/include/CarobException.hpp:1.37 Tue Feb 28 19:50:41 2006
+++ carob/include/CarobException.hpp Tue Mar 7 12:17:44 2006
@@ -248,6 +248,20 @@
};
/**
+ * Exception thrown when an attempt to convert a value (typically in a result
+ * set) to another type fails
+ */
+class ConversionException : public DriverException
+{
+public:
+ /**
+ * Constructs a CodecException with the given message
+ * @param s error message of the exception
+ */
+ ConversionException(std::wstring s) : DriverException(s) {};
+};
+
+/**
* Exception thrown when client tries to retrieve a value that is NULL,
* typically via GetString() GetInt(), etc.
*/
Index: carob/include/DriverResultSet.hpp
diff -u carob/include/DriverResultSet.hpp:1.32
carob/include/DriverResultSet.hpp:1.33
--- carob/include/DriverResultSet.hpp:1.32 Thu Mar 2 16:01:36 2006
+++ carob/include/DriverResultSet.hpp Tue Mar 7 12:17:44 2006
@@ -187,10 +187,12 @@
* @throw DriverException if the ResultSet is closed or the cursor is out of
* bounds
* @throw NullValueException if the retrieved value is NULL
+ * @throw ConversionException if the retrieved value cannot be converted to
+ * a float
*/
int getAsInt(int columnIndex) throw (DriverException,
- NullValueException, NotImplementedException,
- UnexpectedException);
+ NullValueException, ConversionException,
+ NotImplementedException,
UnexpectedException);
/**
* Gets the 64bits integer value of a column in the current row only if the
* given column is of int type, throws an exception otherwise. To get the
@@ -216,10 +218,12 @@
* @throw DriverException if the ResultSet is closed or the cursor is out of
* bounds
* @throw NullValueException if the retrieved value is NULL
+ * @throw ConversionException if the retrieved value cannot be converted to
+ * a float
*/
int64_t getAsInt64(int columnIndex) throw
(DriverException,
- NullValueException, NotImplementedException,
- UnexpectedException);
+ NullValueException, ConversionException,
+ NotImplementedException,
UnexpectedException);
/**
* Gets the float value of a column in the current row only if the
* given column is of float type, throws an exception otherwise.
@@ -244,10 +248,12 @@
* @throw DriverException if the ResultSet is closed or the cursor is out of
* bounds
* @throw NullValueException if the retrieved value is NULL
+ * @throw ConversionException if the retrieved value cannot be converted to
+ * a float
*/
float getAsFloat(int columnIndex) throw
(DriverException,
- NullValueException, NotImplementedException,
- UnexpectedException);
+ NullValueException, ConversionException,
+ NotImplementedException,
UnexpectedException);
/**
* Gets the double value of a column in the current row only if the
* given column is of double type, throws an exception otherwise.
Index: carob/src/DriverResultSet.cpp
diff -u carob/src/DriverResultSet.cpp:1.44 carob/src/DriverResultSet.cpp:1.45
--- carob/src/DriverResultSet.cpp:1.44 Fri Mar 3 18:19:15 2006
+++ carob/src/DriverResultSet.cpp Tue Mar 7 12:17:44 2006
@@ -322,7 +322,8 @@
}
int DriverResultSet::getAsInt(int columnIndex) throw (DriverException,
- NullValueException, NotImplementedException, UnexpectedException)
+ NullValueException, ConversionException, NotImplementedException,
+ UnexpectedException)
{
checkRowAndColPosAndSetNullFlag(columnIndex);
@@ -350,7 +351,7 @@
ret = 0;
else //we cannot do more... throw an exception
{
- throw (DriverException(L"The value (" + valAsString
+ throw (ConversionException(L"The value (" + valAsString
+ L") cannot be converted to int"));
}
}
@@ -424,7 +425,8 @@
}
int64_t DriverResultSet::getAsInt64(int columnIndex) throw (DriverException,
- NullValueException, NotImplementedException, UnexpectedException)
+ NullValueException, ConversionException, NotImplementedException,
+ UnexpectedException)
{
checkRowAndColPosAndSetNullFlag(columnIndex);
@@ -452,7 +454,7 @@
ret = 0;
else //we cannot do more... throw an exception
{
- throw (DriverException(L"The value " + valAsString
+ throw (ConversionException(L"The value " + valAsString
+ L" is not a valid int number"));
}
}
@@ -526,7 +528,8 @@
}
float DriverResultSet::getAsFloat(int columnIndex) throw (DriverException,
- NullValueException, NotImplementedException, UnexpectedException)
+ NullValueException, ConversionException, NotImplementedException,
+ UnexpectedException)
{
checkRowAndColPosAndSetNullFlag(columnIndex);
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits