what's the recommended approach for performing the equivalent of a catch around apply_svalue()?
I've got some code that uses apply_svalue() that is called by code i don't have access to, and I don't want a thrown error to break out of that code (that I don't have access to). suggestions are welcome!
bill
what's the recommended approach for performing the equivalent of a catch around apply_svalue()?
The most common approach is to use safe_apply_svalue(), it unfortunately only supports two error handling modes; either passing errors along to master()->handle_error(), or ignoring them entirely. If you want some other behaviour, you will need to set up the error recovery context yourself (cf interpret.c:safe_apply_svalue()).
bill
Very good. I had been looking at that, just wanted to be sure it was the Approved(tm) method.
Bill
The most common approach is to use safe_apply_svalue(), it unfortunately only supports two error handling modes; either passing errors along to master()->handle_error(), or ignoring them entirely. If you want some other behaviour, you will need to set up the error recovery context yourself (cf interpret.c:safe_apply_svalue()).
JMP_BUF recovery; if(SETJMP(recovery)) { /* an exception was thrown, value in throw_value */ } else { apply_svalue(...); /* no exception was thrown */ } UNSETJMP(recovery);
Btw, shouldn't throw_value and throw_severity really be fields in the Pike_interpreter struct?
pike-devel@lists.lysator.liu.se