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   | 
		 
		
			
				
				
				
					
						  
						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   
 
THX, Hans 
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
  
 
Goto Forum:
 
 Current Time: Tue Nov 04 14:06:21 CET 2025 
 Total time taken to generate the page: 0.05804 seconds 
 |