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
ThrowValueTypeError small bug, and suggestion for removing it [message #42887] Sun, 13 April 2014 13:47 Go to previous message
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
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
 
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: Sun Apr 28 09:17:22 CEST 2024

Total time taken to generate the page: 0.06742 seconds