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
|
|
|
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: 14255 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.
|
|
|
Re: ThrowValueTypeError small bug, and suggestion for removing it [message #42908 is a reply to message #42891] |
Mon, 14 April 2014 07:45  |
busiek
Messages: 70 Registered: February 2011 Location: Poland
|
Member |
|
|
Commit 7243 breaks compilation under g++. For instance when compiling ide following error shows up:
----- ide/Common ( GUI MT GCC SHARED LINUX POSIX ) (1 / 36)
ComDlg.cpp
Module.cpp
Util.cpp
In file included from /home/kubus/src/upp/uppsrc/Core/Core.h:244:0,
from /home/kubus/src/upp/uppsrc/Esc/Esc.h:4,
from /home/kubus/src/upp/uppsrc/ide/Core/Core.h:4,
from /home/kubus/src/upp/uppsrc/ide/Common/Common.h:4,
from /home/kubus/src/upp/uppsrc/ide/Common/ComDlg.cpp:1:
/home/kubus/src/upp/uppsrc/Core/Defs.h:794:27: error: expected class-name before '{' token
class Exc : public String {
^
/home/kubus/src/upp/uppsrc/Core/Defs.h:797:12: error: 'String' does not name a type
Exc(const String& desc) : String(desc) {}
^
|
|
|
Goto Forum:
Current Time: Tue Apr 29 01:53:09 CEST 2025
Total time taken to generate the page: 0.01165 seconds
|