Re: [Nbd] About error management
- To: Tuomas Jorma Juhani Räsänen <tuomasjjrasanen@...1261...>
- Cc: nbd-general@lists.sourceforge.net
- Subject: Re: [Nbd] About error management
- From: Wouter Verhelst <w@...112...>
- Date: Sat, 29 Dec 2012 12:41:12 +0100
- Message-id: <20121229114112.GJ30316@...3...>
- In-reply-to: <20121228143451.GA25919@...1259...>
- References: <20121228143451.GA25919@...1259...>
You really know how to dig up the worst warts in nbd, don't you? ;-)
On Fri, Dec 28, 2012 at 04:34:51PM +0200, Tuomas Jorma Juhani Räsänen wrote:
> Hi
>
> Now that I've started to work on generalizing the dynamic
> reconfiguration hack, I bumped into the quite complex or at least
> unnecessarily complex error mangement scheme currently used in
> nbd-server.c. There seems to be several different error reporting
> styles: fprintf(), msgX(), g_warning(), perror(). Maybe we could try
> to uniform this somehow?
Yes, that code is pretty hary. It was already there when I first
inherited the nbd tools; I just never got around to cleaning it up.
> But the real problem is, that in many places, error reporting and
> handling is tightly coupled and buried inside utility functions. Uses
> of err() or perror() followed by exit() are good examples. I do
> realize that there probably hasn't been a real need for separating
> reporting from handling earlier, but now there is. To exploit the
> existing code base, error handling (i.e. the decisions to what to make
> in case of an error) needs to be separeted from error reporting:
> calling a function which might call exit() in the middle of a
> reconfiguration process is obviously going to cause troubles sooner or
> later.
True.
> My suggestion is that because we are already depending on libglib and
> using it's error reporting framework in few places, we should try to
> use the same mechanism everywhere. In other words, we should pass
> GError** to functions requiring an error reporting mechanism and then
> make the error handling decisions in the caller.
>
> Thoughts?
I've been planning on generalising error handling in precisely that way;
in fact, there is already one place where I do use a GError** parameter.
It just isn't being done consistently yet, because it would be a massive
undertaking to refactor the code in that way.
If you were to do that, I'd owe you a beer. Seriously.
--
Copyshops should do vouchers. So that next time some bureaucracy requires you
to mail a form in triplicate, you can mail it just once, add a voucher, and
save on postage.
Reply to: