Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » ThrowValueTypeError small bug, and suggestion for removing it
Re: ThrowValueTypeError small bug, and suggestion for removing it [message #42891 is a reply to message #42887] Sun, 13 April 2014 19:47 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13976
Registered: November 2005
Ultimate Member
hans wrote on Sun, 13 April 2014 11:47
Hi again, here is small bug (imho)
void ThrowValueTypeError(const String& text, const Value& src, int target)
{
	ValueTypeError err;
	(String&)err = text;
	err.src = text;               // <-- bug, should be err.src= src;
	err.target = target;
	throw err;
}


I would suggest removing this function, instead code following:
class ValueTypeError : public Exc {
public:
	ValueTypeError(const String& text, const Value& src, int target) : Exc(text), src(src), target(target) {}
	Value src;
	int   target;
};


to throw then code
	throw ValueTypeError(String().Cat() << "Invalid value conversion: "
	                    << GetName() << " -> " << typeid(T).name(),
	                    *this, t);


Also no need to return something after the throw to silence the compiler Razz

THX, Hans


Thank you, you are right, code changed.
 
Read Message
Read Message
Read Message
Previous Topic: Base Exception class behavior change
Next Topic: Can we have a ValueMap(Unique) ?
Goto Forum:
  


Current Time: Sat May 11 18:47:12 CEST 2024

Total time taken to generate the page: 0.02088 seconds