From: Warren Young Date: December 12 2005 2:06pm Subject: Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "d List-Archive: http://lists.mysql.com/plusplus/5261 Message-Id: <439D83DF.6060303@etr-usa.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090407050305030709080509" --------------090407050305030709080509 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Drew Vogel wrote: > On line 4 below, a BadConversion exception is thrown, with the what() > message of: > > Tried to convert "0.00P\uffffI" to a "d I don't know why the message is truncated. Try the attached patch, to see if the symptom changes. It just changes the way this message is constructed. As for why the error occurs, if the data truly is accurately represented in that error, then there's no wonder it runs into a bad conversion. That most definitely is not a valid double. What do you get when you use the basic 'mysql' command-line client to dump the data from this row? What if you try casting that fourth field to a std::string instead? --------------090407050305030709080509 Content-Type: text/plain; name="conv-error.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="conv-error.patch" Index: coldata.h =================================================================== --- coldata.h (revision 1143) +++ coldata.h (working copy) @@ -46,6 +46,7 @@ #include #include +#include #include @@ -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); } Index: exceptions.h =================================================================== --- exceptions.h (revision 1140) +++ exceptions.h (working copy) @@ -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 : "")), type_name(tn), data(d), retrieved(r), --------------090407050305030709080509--