Re: Error handling



Philip Van Hoof wrote:
> We have to do something about them .. errors.

Sure.

> I mostly simply ignore them (because my opinion is that too many people
> develop with ONLY errors in mind, whereas errors should be handled in
> the highest possible layer -- by displaying an error message -- in case
> the code can't recover from an error by doing what is expected).
> 
> For making it more simple for myself (prioritising things) I simply
> printed some warnings whenever an error happens.
> 
> I know right error handling requires adding a GError** parameter to
> quite a lot methods. I'm not afraid if such an API change at this
> moment.

I agree with that, I don't think tinymail needs a more complicated error
scheme. I can help with this (not a lot because I'm working in other
stuff but it's still an aid).

Maybe we can do something like:

typedef enum _TnyError TnyError;
enum _TnyError {
TNY_ERROR_PERMISSION_DENIED,
TNY_ERROR_CONNECTION_UNAVAILABLE,
etc
};

GError *tny_error_new (TnyError error_number, const gchar *msg, ...);

void tny_set_error(GError** err, TnyError error_number, const gchar*
msg, ..);

both with variable arguments. Each TnyError will have associated an
error string (defined for example into the .c file). The GError will
include both this string and the one set by the user.

Just a proposal.

Br



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