
Adobe Acrobat SDK
Handling Exceptions
Developing Plug-ins and Applications
Using nested exception handlers 216
This action leads to unpredictable results because the top stack frame has not been removed. As a result,
the frame is incorrect. Instead, use the
ASRaise
method and then use the
goto
statement within the
HANDLER END_HANDLE
block, as shown in the following example:
DURING ...
ASRaise(myspecialerrorcode);
HANDLER
if ERRORCODE == myspecialerrorcode
goto error;
END_HANDLER
error:
Note:
For information about the
goto
statement, see the
Acrobat and PDF Library API Reference
.
Using nested exception handlers
Avoid using nested exception handlers within a single function. The exception handling macros change
the call stack, and nesting them can disrupt the stack. Your plug-in can safely nest an exception handler if
the nested handler is in another function called inside the
DURING HANDLER
block, as shown in the
following example:
DURING
...
MyFunction();
...
HANDLER
...
END_HANDLER
...
void MyFunction(void)
...
DURING
...
HANDLER
...
END_HANDLER
...
}
If you insist on nesting exception handlers in a single function, do not return from the inner exception
handler (either through a call to return in a handler or
E_RETURN
from body code). This action leaves the
exception stack out of sync with the call stack. Any errors raised in body code surrounded by the outer