Re: Weird exceptions policy in glibmm/giomm



Am Freitag, den 03.07.2009, 20:34 +0200 schrieb Tomasz Jankowski:

> 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.

Nearly all exceptions thrown directly by *mm code are wrapped GError
instances.  If there is a GError in the C API, it will be an exception
in the C++ API.  Normally, the exceptions should be listed in the *mm
documentation as well.  If not, it's a documentation bug.

> 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 ()).

That's an API bug, but fortunately mostly harmless.  Just ignore the
return value, it will always be true when the function actually returns.

> I also found few functions, which
> only throws exceptions (Glib::KeyFile::set_comment ()).

Yes, that's how it should normally be.  The boolean return value is
redundant and useless in the C++ API.  But the behavior is the same.

> 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 ()'.

That's because the documentation is machine-translated from the C
documentation.  This doesn't always work perfectly, in which case we
need to add manual overrides.  Again, this is a documentation bug which
should be filed on bugzilla.gnome.org.  A patch would be great!

> I use GTK+ within C++, but some I decided to move to GTKMM to get rid
> of C drawbacks and write in pure C++. So far I continue using GTK+...

It isn't as bad is it looks at first glance.  The documentation is
flawed, and the examples messy, but the library itself is pretty solid.
We are working on improving the docs and examples.  Help would be
appreciated! :-)

Cheers,
--Daniel




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