Re: commit -- MEGA patch, additional error messages


Subject: Re: commit -- MEGA patch, additional error messages
From: sam th (sam@bur-jud-118-039.rh.uchicago.edu)
Date: Thu Jan 27 2000 - 00:33:47 CST


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 26 Jan 2000, Paul Rohr wrote:

> 2. Sam changed a few functions to return UT_Error instead of UT_Bool, which
> is a good idea overall. However, this *reverses* the usual bang semantics.
> After tracking down a few bugs related to this, I introduced the following
> ut_types.h macro:
>
> #define E2B(err) ((err) == UT_OK)
>
> All it does is reverse those bang semantics back to something meaningful.
>
>
> Enjoy!
>
> Paul
>

In terms of bang semantics, what Paul has done is a good idea, but in
general, we should avoid using it (or the bang). Here's why:
<preach>
If you are using the syntax if(E2B(fucntion(..))) then you are missing
important information. You are treating the error as a substitute for a
Bool, which it is not. If you find yourself using this sytax, you should
ask yourself "What should I do with this information that I have been
given, and how should I let the user know about it?" The construction
that I like is

UT_Error error = function(...);
if(error)
        // handle error, using the information you have been given
else
        // it worked

I find if(error) to be fairly readable, also.
</preach>
Sorry about preaching, but I think informative error messages go along way
to making Abiword easy to use.
           
                                     sam th
                                     sytobinh@uchicago.edu
                        
PS - If you have a question about error handling, feel free to email me.
                
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE4j+bMt+kM0Mq9M/wRAmsdAJ9cJFG2YXNooAia6AvwN5MysWiOHACfYYhq
Sq0O/f+D9MNQ3md9k53Ej0M=
=8ZWl
-----END PGP SIGNATURE-----



This archive was generated by hypermail 2b25 : Thu Jan 27 2000 - 00:33:49 CST