[cairo] error handling
brian.ewins at gmail.com
Wed May 30 03:07:54 PDT 2007
On 30/05/07, Behdad Esfahbod <behdad at behdad.org> wrote:
> Quickly checked a couple of them. Seems like in
> cairo_scaled_font_glyph_extents() and probably others, you return any
> error that happens. I don't think that quite works. For example, if an
> out of memory error happens, we want to still keep the error in the
> object. Only the "ignorable" errors should be returned immediately. In
> this case, out-of-range glyph id is the only such error.
Ok, I was going with the do-one-or-the-other behaviour elsewhere in
the code, and because I think there are more recoverable conditions
than that one - as in, you may be able to keep drawing but the output
is not exactly what you asked for, same as in the missing glyph case.
And, OOM errors are not kept for set_user_data? But I'm happy to
change the patches.
So do you want this:
if (status && status != CAIRO_STATUS_INVALID_GLYPH)
if (status == CAIRO_STATUS_INVALID_GLYPH)
I can see justifications for both. In the first case, you don't need
to check two different statuses to see if anything went wrong; in the
second case warnings and errors don't get mixed together. Which would
> I don't see why you changed cairo_set_font_face and
> cairo_select_font_face at all.
I was putting it in the category of 'bad user input that cairo can
recover from'. The behaviour of what happens if you select a
non-existent face isn't documented, and isn't programmer error. But, I
guess this is better fixed by fixing the documentation to describe
that it's just a best-effort font you get. Dropped.
I think doing set_font_face was just daftness on my part. It can only
ever return programmer errors.
More information about the cairo