[cairo] API: get error message

Uli Schlachter psychon at znc.in
Sat Nov 11 09:32:18 UTC 2017


On 11.11.2017 09:53, Adrian Johnson wrote:
> There a number of status types where cairo could report additional
> information on the error:

How would such an error message look like?

>  CAIRO_STATUS_PNG_ERROR

Looking at cairo-png.c, the extra info here would be the error message
provided by libpng, I guess? (png_simple_error_callback() in cairo-png.c)

>  CAIRO_STATUS_FREETYPE_ERROR

This is a catch-all for most FT_Error values. Does freetype provide its
own error strings here or do you plan to invent your own descriptions?
(_ft_to_cairo_error() in cairo-ft-font.c)

>  CAIRO_STATUS_WIN32_GDI_ERROR

Heh. :-)

_cairo_win32_print_gdi_error() currently (as the name implies) just
prints the error to stderr and then returns this error code. Do you want
to get rid of this print-to-stderr?

Also, the error messages here (specifically: the context argument to the
above function) seem quite internal to me, mentioning names of static
functions. What's the exact plan here?

>  CAIRO_STATUS_TAG_ERROR

This one seems to be purely cairo-internal, so the least of a problem.

> Currently the status just tells us something went wrong. With the above
> status types there could be multiple reasons why it might fail.
> 
> I'd like to introduce a new function that can retrieve the reason for
> the failure.
> 
> const char *
> cairo_surface_get_error_explanation()
> 
> Returns NULL if no error explanation available for the current status
> type (including SUCCESS). The returned string is owned by the surface
> and will be destroyed when the surface is destroyed.

Why only for surfaces? For example, the freetype errors likely end up
being on a font face and the win32 error will most likely be encountered
on a cairo context.

Uli
-- 
"Do you know that books smell like nutmeg or some spice from a foreign
land?"
                                              -- Faber in Fahrenheit 451


More information about the cairo mailing list