Re: Weird exceptions policy in glibmm/giomm



On Fri, 2009-07-03 at 20:34 +0200, Tomasz Jankowski wrote:
> Hello!
> 
> I'm trying to figure out exceptions policy in glibmm/giomm. It's hard
> to understand which functions exactly throw exceptions. I made some
> research (I read API and source code), but this issue stays still
> unclear for me.

Generally, the docs should say if a function throws an exception or not.
If they don't, the docs need improvement.  Filing a bug (with a patch
possibly) generally takes care of the lack of clarity.

> As I see there is no exceptions policy for whole project. Some
> functions handle exceptions only by returning bool value (example:
> Glib::file_test ()).and other return both bool and throw exceptions
> (Glib::KeyFile::load_from_file ()). I also found few functions, which
> only throws exceptions (Glib::KeyFile::set_comment ()).

Generally, the functions are simply a reflection of the C API.  If the
function in the C API returns a bool, the C++ function will most
probably also return a bool.  Exceptions are generally thrown if the C
function has a a GError output parameter as in
g_key_file_load_from_file[1].

[1]
http://library.gnome.org/devel/glib/2.21/glib-Key-value-file-parser.html#g-key-file-load-from-file

> I thought that API will explain everything, but it didn't. Example,
> description for  Glib::KeyFile::set_comment () doesn't mention, that
> function throws exception... Moreover I found some bugs in
> documentation, for example  documentation specify return value for
> (again...) 'void Glib::KeyFile::set_comment ()'.

Once more, filing a bug will generally inform the maintainers so the
missing information can be added to the docs.  Feel free to file one to
improve the docs.


-- 
José Alburquerque



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]