[geos-devel] GEOSException is incompatible with std::exception
Mateusz Łoskot
mateusz at loskot.net
Tue Apr 4 10:44:31 EDT 2006
strk at refractions.net wrote:
> Good catch Mateus, anyway there's no std::exception(const char*)
> interface in my STL implementation (GCC 3.3).
> [...]
Yes, sorry, that's my fault.
I used unstandard STL.
Let's make it clear. Standard version of exception class is:
class exception {
public:
exception() throw();
exception(const exception& right) throw();
exception& operator=(const exception& right) throw();
virtual ~exception() throw();
virtual const char *what() const throw();
};
what() is virtual, so next we have many derived classes:
class logic_error : public exception {
public:
logic_error(const string& message);
};
Here, logic_error has it's own version of message member, but becasue
what() is virtual, proper string is returned.
> We can pick one of the derivated classes like runtime_exception
> insted. That one allows contruction taking 'const string&'.
> It's defined in <stdexcept>.
Yes, as I corrected myself above.
> What do you think ?
Honestly, I don't think al GEOS exceptions can be categorized as
runtime_exception, some are logical e.g. IllegalArgumentException.
GEOSException is a general geos exception and I think it should be
derived directly from std::exception.
GEOSException could be defined similarly as those exceptions in
<stdexcept> file.
What do you think?
Cheers
--
Mateusz Łoskot
http://mateusz.loskot.net
More information about the geos-devel
mailing list