Date: Monday, March 13, 2006 @ 20:31:04
Author: marc
Path: /cvsroot/carob/carob
Modified: include/CarobException.hpp (1.43 -> 1.44) src/BigDecimal.cpp
(1.22 -> 1.23) src/DriverResultSet.cpp (1.49 -> 1.50)
Added standard SQLStates for ConversionException and NotImplementedException
----------------------------+
include/CarobException.hpp | 20 +++++++++++++++++---
src/BigDecimal.cpp | 27 +++++++++++++++++----------
src/DriverResultSet.cpp | 17 ++++++++++++-----
3 files changed, 46 insertions(+), 18 deletions(-)
Index: carob/include/CarobException.hpp
diff -u carob/include/CarobException.hpp:1.43
carob/include/CarobException.hpp:1.44
--- carob/include/CarobException.hpp:1.43 Mon Mar 13 19:38:30 2006
+++ carob/include/CarobException.hpp Mon Mar 13 20:31:04 2006
@@ -231,8 +231,22 @@
* Constructs a CodecException with the given message
* @param s error message of the exception
*/
- ConversionException(std::wstring s) : DriverException(s) {};
-};
+ ConversionException(std::wstring s, std::wstring state)
+ : DriverException(s, state)
+ { };
+};
+/** Errors */
+const std::wstring CONV_NUM_RANGE(L"22003");
+const std::wstring CONV_DATE_INVALID(L"22007");
+const std::wstring CONV_DATE_RANGE(L"22008");
+const std::wstring CONV_INTERVAL(L"22015"); // we don't support intervals
+const std::wstring CONV_CHAR(L"22018");
+
+const std::wstring CONV_INVALID(L"07006");
+
+/** Warnings */
+const std::wstring CONV_STRING_TRUNC(L"01004");
+const std::wstring CONV_NUM_TRUNC(L"01S07"); // missing from standard
/**
@@ -245,7 +259,7 @@
* Constructs a NotImplementedException with the given message
* @param s error message of the exception
*/
- NotImplementedException(std::wstring s) : DriverException(s) {};
+ NotImplementedException(std::wstring s) : DriverException(s, L"HYC00") {};
};
/**
Index: carob/src/BigDecimal.cpp
diff -u carob/src/BigDecimal.cpp:1.22 carob/src/BigDecimal.cpp:1.23
--- carob/src/BigDecimal.cpp:1.22 Fri Mar 10 22:15:45 2006
+++ carob/src/BigDecimal.cpp Mon Mar 13 20:31:04 2006
@@ -199,7 +199,7 @@
{
if (!mpz_fits_sint_p(scaled_int.get_mpz_t()))
throw (ConversionException(L"BigDecimal " + static_cast<wstring>(*this)
- + L" is to big to be converted into an int"));
+ + L" is to big to be converted into an int", CONV_NUM_RANGE));
}
else
{
@@ -208,14 +208,14 @@
mpz_neg(tmp.get_mpz_t(), scaled_int.get_mpz_t());
if (!mpz_fits_sint_p(tmp.get_mpz_t()))
throw (ConversionException(L"BigDecimal " + static_cast<wstring>(*this)
- + L" is to big to be converted into an int"));
+ + L" is to big to be converted into an int", CONV_NUM_RANGE));
}
int mag_length = -1;
int* mag = toIntArray(scaled_int, &mag_length);
if (mag_length <= 0)
{
throw (ConversionException(L"BigDecimal " + static_cast<wstring>(*this)
- + L" could not be converted to int"));
+ + L" could not be converted to int", L"FIXME"));
}
int res = mag[mag_length-1];
delete[] mag;
@@ -236,7 +236,7 @@
{
if (!mpz_fits_slong_p(scaled_int.get_mpz_t()))
throw (ConversionException(L"BigDecimal " + static_cast<wstring>(*this)
- + L" is to big to be converted into a long"));
+ + L" is to big to be converted into a long", CONV_NUM_RANGE));
}
else
{
@@ -245,7 +245,7 @@
mpz_neg(tmp.get_mpz_t(), scaled_int.get_mpz_t());
if (!mpz_fits_slong_p(tmp.get_mpz_t()))
throw (ConversionException(L"BigDecimal " + static_cast<wstring>(*this)
- + L" is to big to be converted into a long"));
+ + L" is to big to be converted into a long", CONV_NUM_RANGE));
}
return (signum > 0 ? scaled_int.get_si() : -scaled_int.get_si());
}
@@ -265,14 +265,14 @@
nbBitsNeeded++; // count the sign bit. Negative overflow will be detected
later (TODO)
if (nbBitsNeeded > sizeof(int64_t)*8)
throw (ConversionException(L"BigDecimal " + static_cast<wstring>(*this)
- + L" is too big to be converted into an int64_t"));
+ + L" is too big to be converted into an int64_t", CONV_NUM_RANGE));
int mag_length = -1;
int* mag = toIntArray(scaled_int, &mag_length);
if (mag_length <= 0) //should not happen, but safer
{
throw (ConversionException(L"BigDecimal " + static_cast<wstring>(*this)
- + L" could not be converted to int64"));
+ + L" could not be converted to int64", L"FIXME"));
}
int64_t result = 0;
@@ -293,7 +293,7 @@
return 0;
if (signum < 0)
throw (ConversionException(L"BigDecimal " + static_cast<wstring>(*this)
- +L" is negative ! it cannot be converted into an int64_t"));
+ +L" is negative ! it cannot be converted into an int64_t",
CONV_NUM_RANGE));
mpz_class scaled_int = toBigInteger();
if (mpz_cmp_d(scaled_int.get_mpz_t(), 0) == 0) // if scaled_int == 0
return 0;
@@ -301,14 +301,14 @@
size_t nbBitsNeeded = mpz_sizeinbase(scaled_int.get_mpz_t(), 2);
if (nbBitsNeeded > (sizeof(int64_t)*8))
throw (ConversionException(L"BigDecimal " + static_cast<wstring>(*this)
- + L" is too big to be converted into an int64_t"));
+ + L" is too big to be converted into an int64_t", CONV_NUM_RANGE));
int mag_length = -1;
int* mag = toIntArray(scaled_int, &mag_length);
if (mag_length <= 0) //should not happen, but safer
{
throw (ConversionException(L"BigDecimal " + static_cast<wstring>(*this)
- + L" could not be converted to int64"));
+ + L" could not be converted to int64", L"FIXME"));
}
uint64_t result = 0;
@@ -358,3 +358,10 @@
}
+/*
+ * Local Variables:
+ * c-file-style: "bsd"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * End:
+ */
Index: carob/src/DriverResultSet.cpp
diff -u carob/src/DriverResultSet.cpp:1.49 carob/src/DriverResultSet.cpp:1.50
--- carob/src/DriverResultSet.cpp:1.49 Fri Mar 10 22:18:20 2006
+++ carob/src/DriverResultSet.cpp Mon Mar 13 20:31:04 2006
@@ -352,7 +352,7 @@
else //we cannot do more... throw an exception
{
throw (ConversionException(L"The value (" + valAsString
- + L") cannot be converted to int"));
+ + L") cannot be converted to int", CONV_INVALID));
}
}
}
@@ -454,7 +454,7 @@
else //we cannot do more... throw an exception
{
throw (ConversionException(L"The value " + valAsString
- + L" is not a valid int64 number"));
+ + L" is not a valid int64 number", CONV_INVALID));
}
}
}
@@ -536,7 +536,7 @@
else //we cannot do more... throw an exception
{
throw (ConversionException(L"The value " + valAsString
- + L" is not a valid uint64 number"));
+ + L" is not a valid uint64 number", CONV_INVALID));
}
}
}
@@ -640,7 +640,7 @@
else //we cannot do more... throw an exception
{
throw (ConversionException(L"The value " + valAsString
- + L" is not a valid float number"));
+ + L" is not a valid float number", CONV_INVALID));
}
}
}
@@ -742,7 +742,7 @@
else //we cannot do more... throw an exception
{
throw (ConversionException(L"The value " + valAsString
- + L" is not a valid double number"));
+ + L" is not a valid double number", CONV_INVALID));
}
}
}
@@ -962,3 +962,10 @@
}
+/*
+ * Local Variables:
+ * c-file-style: "bsd"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * End:
+ */
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits