Re: popt

->  - has error reporting; we still lack a standard glib error
->    reporting setup

	Can anyone recommend a good reference for structured
error-handling techniques?

	In my own code, I've used the following (simple out-of-band)

If the function returns a pointer, NULL means an error occured.  This has
the problem that sometimes a pointer-returning function can return NULL as
a valid value, thus breaking the convention.

If the function returns a value that could be a guint (such as
length, time, or any other value where a negative does not make sense) I
have the function return a gint, where <0 indicates an error occurred.
This has the advantage that you can use enumerated error codes, i.e. -1
means one thing, -2 means something else, etc.  In my own code, I don't
usually go as far as enumerated error values, but it's possible...

In functions that would normally return void, I have it return a gint
instead, where <0 indicates an error occurred (or 0 for success).

	These are obviously very simple rules, but short of orchestrating
some elaborate message-passing, exception-throwing architecture, what else
can you do with C?

-> Thoughts? Maybe we should fork off the codebase? That sort of sucks on
-> one hand, but on the other hand it's only 600 lines of code.

	(My $.02: I would have no issue with forking from popt...)

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