|
Geometry : |
Subject: [ggl] Definition of exception types
From: Mateusz Loskot (mateusz)
Date: 2009-06-14 08:02:11
Barend Gehrels wrote:
>> I'd like to collect some thoughts and guidelines about exception types
>> defined in GGL.
>>
>> Do we stick to Boost guidelines [1] ?
>>
>> Should we have abstract ggl::exception defined as std::exception
>> subclass and derive all other exceptions from it?
>
> I just added it on Friday. Just committed it. So yes, good idea.
Great. I'll take a look at it.
>> I'd suggest to prefer to std:: naming with _error postfix, for instance
>> ggl::wkb::value_error, than what I have now:
>> ggl::value_wkb_exception
>> and others.
>
> OK for me, but what is the reason to prefer _error above _exception?
Nothing big. I just was thinking about following naming used in
<stdexcept> types.
>> Among others, there seems to be two structures popular:
>>
>> 1. All GGL exceptions live directly in ggl:: and are defined in single
>> file, for instance:
>>
>> ggl::wkb_value_error
>> ggl::wkb_read_error
>>
>> 2. Exceptions are categorized using namespace
>>
>> ggl::wkb::value_error
>> ggl::wkb::read_error
>> ggl::wkb::write_error
>> ggl::wkt::write_error
>> ...
>> ggl::algorithm::intersection_error
>> ...
>>
>> Which to prefer?
>
> I prefer to have exceptions close to which module they belong, so not in
> a single file. This makes modularization more easy.
I agree with that. I like the effect of modularisation.
> Or is there another reason to have everything in a single file?
Perhaps it's easier to users to find out what header to include if they
want to catch exception.
> The namespaces look OK to me, but it can grow and is subject to
> discussion, because you can follow the folder structure or the
> namespaces to which a module belong...
>
> ggl::io::wkt::empty_error ...
Sometimes namespaces layout may not be reflected in folders structure,
but namespaces seems to be more logically structured.
Thus, I think namespace is a good categorization criteria for exceptions.
What you think?
Cheers,
-- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org
Geometry list run by mateusz at loskot.net