Re: [AD] 4.3 error handling

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Wednesday 07 June 2006 19:41, Peter Wang wrote:
> What happens if I write an Allegro addon that uses the try-catch
> mechanism, but the user's application does not?  And vice versa?

I thought about that. And I've implemented al_error_throws_are_enabled (name 
subject to change :P). You could save that value before setting the mode you 
want, then check it before you exit out of your code.

> > "setjmp() and longjmp() are useful for dealing with errors and interrupts
> > encountered in a low-level subroutine of a program"
> >
> > This is exactly what it's being used for.
>
> Because you can end up bypassing a lot of cleanup code, setjmp/longjmp
> should remain in the realm of "last resort" and definitely not exposed
> to the user, even through macros.  As soon as two libraries tried to use
> setjmp for error handling, you're stuffed.

This method of using setjmp/longjmp makes it easier to handle cleanup code, by 
making sure you get back into your code at a specific location if an error 
occurs. And setjmp stores the state/position in a local (to the library) 
variable. A library setting a jmp_buf variable wouldn't effect another 
library setting another jmp_buf variable.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/