[cairo] Making it easier to track down errors

Olivier Andrieu oliv__a at users.sourceforge.net
Thu Jun 16 13:55:54 PDT 2005


 > Carl Worth [Wed, 15 Jun 2005]:
 > 
 > On Tue, 14 Jun 2005 08:41:49 +0200, Mathieu Lacage wrote:
 > > I have been burned by this kind of API before and I cursed the
 > > authors of the code more than once. Specifically, I wished they
 > > had done something like this:
 > > 
 > > 1) add a function pointer to their structure which is invoked
 > >    whenever the error is detected
 > > 2) add a public setter for this function pointer
 > > 3) initialize it by default to _cairo_error.
 > 
 > That's a very reasonable request. Since the work in the previous
 > patch is a prerequisite to doing this, and since nobody else has
 > complained about it, I just committed that patch.
 > 
 > And here's a patch to implement what you asked for. The new
 > functionality is:
 > 
 > 	typedef void (*cairo_error_notify_func_t) (void *closure, * cairo_status_t status);
 > 	void
 > 	cairo_set_error_notify (cairo_t			 *cr,
 > 				cairo_error_notify_func_t error_notify,
 > 				void			 *closure);
 > 
 > One difference between the implementation here and the suggestion
 > above is that here _cairo_error is always called on an error so that
 > the break on _cairo_error trick will always work whether or not an
 > error_notify handler is in place. It's _cairo_error that actually
 > calls the error notify handler (which is simply NULL by default).

Nice. Would it be safe for language bindings to raise exceptions at
this point ? (That means that the _cairo_error() call would not return
and the calling function should have done all its cleanup before it
calls _cairo_error).

-- 
   Olivier



More information about the cairo mailing list