Author: wyoung
Date: Mon Dec 12 15:08:11 2005
New Revision: 1152
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1152&view=rev
Log:
Changed the way data conversion exception error messages are
constructed: instead of using a chain of string '+' operations, we use
an ostringstream object instead. This is the proper C++ idiom for this
kind of thing.
Modified:
trunk/lib/coldata.h
trunk/lib/exceptions.h
Modified: trunk/lib/coldata.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/coldata.h?rev=1152&r1=1151&r2=1152&view=diff
==============================================================================
--- trunk/lib/coldata.h (original)
+++ trunk/lib/coldata.h Mon Dec 12 15:08:11 2005
@@ -46,6 +46,7 @@
#include <typeinfo>
#include <string>
+#include <sstream>
#include <stdlib.h>
@@ -324,7 +325,10 @@
}
if (*end != '\0' && end != 0) {
- throw BadConversion(typeid(Type).name(), Str::c_str(),
+ std::ostringstream outs;
+ outs << "Tried to convert \"" << *this << "\" to a \"" <<
+ typeid(Type).name() << "\" object." <<
std::ends;
+ throw BadConversion(outs.str().c_str(), Str::c_str(),
end - str, len);
}
Modified: trunk/lib/exceptions.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/exceptions.h?rev=1152&r1=1151&r2=1152&view=diff
==============================================================================
--- trunk/lib/exceptions.h (original)
+++ trunk/lib/exceptions.h Mon Dec 12 15:08:11 2005
@@ -103,9 +103,8 @@
/// \param a ??
BadConversion(const char* tn, const char* d,
size_t r, size_t a) :
- Exception(std::string("Tried to convert \"") +
- std::string(d ? d : "") + "\" to a \"" +
- std::string(tn ? tn : "")),
+ Exception(std::string("Bad type conversion: ") +
+ std::string(d ? d : "<NULL>")),
type_name(tn),
data(d),
retrieved(r),