[cairo] error handling questions
spitzak at thefoundry.co.uk
Thu Jul 5 03:01:00 PDT 2007
Although initially I figured Cairo was not complex enough to require it,
it now sounds like it would be nice to return a string describing the
error. This would make code that just wants to dump the error to a log
easy to write and not have to be fixed as new errors are added.
Depending on the error this could be pointers to string constants (this
would be a requirement for out-of-memory), or a buffer allocated and
belonging to the cairo_t. I would think some function would be used to
retrieve the error:
const char* cairo_error_string(cairo_t);
This probably should return null on no error, so that programmers don't
write code the produces stupid-looking log messages (such as the
well-known Windows messages that say "Error: no error").
Behdad Esfahbod wrote:
> On Tue, 2007-07-03 at 10:32 -0700, Carl Worth wrote:
>> On Sun, 01 Jul 2007 15:47:18 -0400, Behdad Esfahbod wrote:
>>> On Mon, 2007-06-18 at 16:52 -0400, Vladimir Vukicevic wrote:
>>>> We've been using CAIRO_STATUS_NO_MEMORY as "unknown error" in a bunch of
>>>> places; I know that it's generally been the policy to use a real error
>>>> code, but would anyone mind if I were to introduce
>>>> CAIRO_STATUS_UNKNOWN_ERROR (or CAIRO_STATUS_FAILURE) so that we can
>>>> distinguish between real OOM and unknown errors?
>>> I'm in favor.
>> Abusing NO_MEMORY was bad, inexcusable, and must be fixed. But adding
>> UNKNOWN_ERROR is not any better, (and worse in that it actually
>> _looks_ like it's intended as a random catch-all).
More information about the cairo