[Top][All Lists]

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

Re: Error messages again

From: Ben Pfaff
Subject: Re: Error messages again
Date: Thu, 18 May 2006 08:46:02 -0700
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

John Darrington <address@hidden> writes:

> On Thu, May 18, 2006 at 07:06:53AM -0700, Ben Pfaff wrote:
>      John Darrington <address@hidden> writes:
>      > The "domain" field is roughly equivalent to our class member, so
>      > converting between the two will be resonably straightforward.  But the
>      > "code" member has no equivalent. It needs to be a unique number for
>      > each error message.
>      What does the "code" member actually get used for?  i.e. is there
>      a reason we should actually care that it is unique?
> There's a function :
> /* Returns TRUE if error matches domain and code, FALSE otherwise. */
> gboolean    g_error_matches                 (const GError *error,
>                                              GQuark domain,
>                                              gint code);
> So the (domain, code) pair should be unique.

OK.  But how would a pair of matching messages be treated
differently from a pair of differing messages, and does the
difference in treatment warrant actually trying to make them

>      > I'm not sure how we'd implement that.  One idea would be to  have it
>      > initialsed whenever the function msg is called: Change msg to a macro,
>      > and initialise code to a hash of the __FILE__, __LINE__ combination.

I don't like the idea of changing msg to a macro.  It's nasty, in
my opinion.

I'd suggest initializing "code" as a hash of the message text.  I
don't know whether, e.g. "ABC is an unknown identifier." and "XYZ
is an unknown identifier." are different messages, so we could
try to get the hash before the formatting takes place, so that it
would actually be a hash of "%s is an unknown identifier."
"I don't want to learn the constitution and the declaration of
 independence (marvelous poetry though it be) by heart, and worship the
 flag and believe that there is a god and the dollar is its prophet."
--Maarten Wiltink in the Monastery

reply via email to

[Prev in Thread] Current Thread [Next in Thread]