[geos-devel] GEOSException is incompatible with std::exception

Mateusz Łoskot mateusz at loskot.net
Wed Apr 5 16:24:39 EDT 2006


strk at refractions.net wrote:
> On Tue, Apr 04, 2006 at 06:59:20PM +0200, Mateusz Å?oskot wrote:
>> strk at refractions.net wrote:
>>> On Tue, Apr 04, 2006 at 04:44:31PM +0200, Mateusz Ã…?oskot wrote:
>>>
>>>> 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?
>>> That's fine with me. Anyway, I think this was previous layout.
>> Yes, indeed.
>> But there were no what() accessor, so that's why the problem occured.
>>
>>> Maybe the problem was GEOSException didn't define what() as a 'const'
>>> method (thus NOT overriding the non-const version) ?
>> Yes, I think so.
>> I've just tested it again and here is my final proposal:
>>
>> 1. GEOSException derives from std::exception
>> 2. GEOSException has it's own member to store the message,
>> similarly to standard exception classes derived from std::exception
>> 3. GEOSException overrides virtual member declared in
>> std::exception::what() to return the message stored in the local buffer
>>
>> Does it make sense?
> 
> I committed a patch in this direction.
> Could you test current CVS with your existing tests please ?

It works.
All GEOS exceptions I catch in Unit Tests have valid message returned by
what().

Cheers
-- 
Mateusz Łoskot
http://mateusz.loskot.net



More information about the geos-devel mailing list