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 |
|
mirek
Messages: 13976 Registered: November 2005
|
Ultimate Member |
|
|
hans wrote on Sun, 13 April 2014 11:47Hi 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
Thank you, you are right, code changed.
|
|
|
Goto Forum:
Current Time: Sat May 11 18:47:12 CEST 2024
Total time taken to generate the page: 0.02088 seconds
|