[cairo] error handling questions

Baz brian.ewins at gmail.com
Wed Jul 4 12:46:02 PDT 2007


On 04/07/07, Carl Worth <cworth at cworth.org> wrote:
> And that leads to misleading bug reports. Which of the following
> replacements would lead to better bug reports?
>
>         cairo is unhappy: unknown error
>
>         cairo is unhappy: GDI error

If we're adding code to dump stacktraces for better bug reporting, we
should also report what that 'unknown' error is. In all the cases
where this is happening in the mac code, we have an OSStatus which we
can't report back via a cairo_status_t. I presume its the same
elsewhere. What I'd prefer is that instead of:

OSStatus err;
cairo_status_t status;
// ...
// quartz error!
if (err != noErr) {
    _cairo_error (CAIRO_STATUS_NOT_REALLY_NO_MEMORY)
   status = CAIRO_STATUS_NOT_REALLY_NO_MEMORY;
   goto BAIL;
}
// a real OOM:
if (!img) {
    _cairo_error (CAIRO_STATUS_NO_MEMORY)
   status = CAIRO_STATUS_NO_MEMORY;
   goto BAIL;
}

we should do this:

// quartz error!
if (err != noErr) {
    // This returns the appropriate backend error code but may also
   // print useful info about 'err' if the debug env var is set.
Internally this will call _cairo_error.
   // GDI errors etc would have a similar backend-specific function.
Its also possible that some
   // inputs can be mapped to existing cairo errors.
   status = _cairo_quartz_error (err);
   goto BAIL;
}
// a real OOM:
if (!img) {
   // get rid of needless repetition while we're at it, or go with vlad's
   // proposal here and eliminate the _cairo_error call entirely.
   status =  _cairo_error (CAIRO_STATUS_NO_MEMORY)
   goto BAIL;
}

This makes no difference if you're using a debugger, but from a bug
report perspective it seems more useful.

-Baz


More information about the cairo mailing list