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 next 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
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 next message
mirek is currently offline  mirek
Messages: 13975
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.
Re: ThrowValueTypeError small bug, and suggestion for removing it [message #42908 is a reply to message #42891] Mon, 14 April 2014 07:45 Go to previous message
busiek is currently offline  busiek
Messages: 64
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) {}
            ^
Previous Topic: Base Exception class behavior change
Next Topic: Can we have a ValueMap(Unique) ?
Goto Forum:
  


Current Time: Thu Mar 28 14:37:19 CET 2024

Total time taken to generate the page: 0.02081 seconds