List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:December 12 2005 2:06pm
Subject:Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "d
View as plain text  
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?

Index: coldata.h
===================================================================
--- coldata.h	(revision 1143)
+++ coldata.h	(working copy)
@@ -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);
 	}
 
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 : "<NULL>")),
 	type_name(tn),
 	data(d),
 	retrieved(r),

Thread
BadConverion::what()=Tried to convert "0.00P\uffffI" to a "dDrew Vogel11 Dec
  • Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "dDrew Vogel11 Dec
  • Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "dWarren Young12 Dec
    • Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "dDrew Vogel12 Dec
      • Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "dWarren Young12 Dec
        • Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "dDrew Vogel12 Dec
          • Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "dWarren Young12 Dec
            • Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "dDrew Vogel12 Dec
          • Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "dDrew Vogel16 Dec
            • Re: BadConverion::what()=Tried to convert "0.00P\uffffI" to a "dChris Frey19 Dec