Re: [AD] 4.3 error handling |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Friday 09 June 2006 05:48, Elias Pschernig wrote:
> However, in C++, it would be perfectly valud to do this, so users simpy
> *will* do it, no matter how big a warning we put into the docs.
Actually, if they put the cleanup code in the respective catch blocks, they'll
have problems too:
try {
try {
al_audio::init();
sfxlib::init();
al_audio::do_something();
sfxlib::do_something();
}
catch(AL_ERROR err) {
al_audio::cleanup();
}
}
catch(SFXLIB_ERROR err) {
sfxlib::cleanup();
}
If sfxlib fails, it'll throw an SFXLIB_ERROR object, which the top-level catch
will ignore because it's not an AL_ERROR object, and thus won't be cleaned
up. Granted though, the setjmp/longjmp method still has the problem of the
last jump point not being cleared.