Re: g_assert vs. g_return_if_fail

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

 



On Thu, 2010-01-21 at 00:17 +0100, Martin Kalbfuß wrote:
> The
> essential question is, why not to use g_assert in libraries. I haven't
> understood the data loss problem.

If "your" library crashes "my" application, I have no chance to do an
emergency save of the user's data, so presumably that's what Behdad is
getting at.

++

In the Java bindings, the Gtk-ERROR etc messages that result from these
g_return_if_fail() sanity tests are converted to unchecked Java
Exceptions. This helps enormously with debugging, but the developer can
_also_ do something like:

        try {
        	Gtk.main();
        } catch (Throwable t) {
                data.emergencySave();
        	throw t;
        }

or such, which means there is at least a chance of attempting to not
lose things.

Whether or not Java's unchecked exceptions is a good idea [or for that
matter whether C programs abruptly terminating on errors] is a topic for
another day :)

AfC
Sydney

-- 
Andrew Frederick Cowie

Operational Dynamics is an operations and engineering consultancy
focusing on IT strategy, organizational architecture, systems
review, and effective procedures for change management: enabling
successful deployment of mission critical information technology in
enterprises, worldwide.

http://www.operationaldynamics.com/

Sydney   New York   Toronto   London

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux