[cairo] cairomm exception handling questions
murrayc at murrayc.com
Wed Aug 13 01:41:26 PDT 2008
On Mon, 2008-08-11 at 15:45 -0300, Ian Britten wrote:
> Murray Cumming wrote:
> > Of course you shouldn't be catching the exceptions for every call.
> > That's why they are exceptions.
> Admittedly, my experience with exceptions is fairly limited.
> However, as a library writer trying to add a Cairo 'canvas' to
> our existing framework, I would think that I would want to catch
> the exceptions, wouldn't I?
Yes, but probably not for every call. Of course, if you are writing lots
of very small functions, just to wrap cairomm, then yes, you don't have
> The higher-level code is certainly
> NOT exception-safe, and I'm trying to ensure no exceptions(*)
> propagate out. [ Thoughts/Suggestions/Guidelines welcome ]
> (*) Admittedly, exceptions like 'new' are a bit different, but I'm
> mostly interested in the cairo-specific errors/problems that I
> can fix/prevent/handle/etc.
> > I think it's more important that we document what exceptions can be
> > thrown by what methods. But to know that we need to know what errors can
> > be set by what C functions and that's lacking from the cairo
> > documentation currently. For instance:
> > http://www.cairographics.org/manual/cairo-PDF-Surfaces.html#cairo-pdf-surface-create
> I'm note sure that an exact listing of errors for each method/function
> (And all the child calls) would be feasible - It'd certainly seem to
> me to be tedious to maintain (And I don't think I'd want to do it!)
It's difficult but we (and cairo) should have it. But it would be much
worse if there were hundreds of cairo have hundreds of error codes.
> However, the information you indicated on that link seems adequate
> for programming with.
The link to the implementation? People should definitely not have to
read the implementation. The API should be documented properly.
> I guess my problem was I had only looked at
> which doesn't give any information about errors.
> Since it throws an exception on bad input, I don't get a surface
> object back to query though, leaving me trying to catch exceptions,
> analyze them, etc.
> >> - What am I expected to do with a Cairo::logic_error exception? I
> >> had been planning to try use the ErrorStatus (cairo_status_t) to
> >> return a meaningful error to the calling code. However, it seems
> >> that I can't access the status (private, no 'get').
> > Good point. I guess there should be a get_error_code() method. A patch
> > would be welcome.
> I'll see what I can do - No promises though (I'm already involved
> with several OpenSource projects, and develop full time all day...)
murrayc at murrayc.com
More information about the cairo