New Forum | Previous | Next | (P-PDF) Developers
Topic: error HANDLER mistake - learn from mine
Conf: (P-PDF) Developers, Msg: 69898
Date: 8/5/2002 10:10 AM
I have just discovered an interesting quirk that made a bug much harder to find.
Here is a simplified version of the error.
nameCos = CosDictGet(dictCos,myKeyAtom);
E_RETURN ( CosNameValue(nameCos));
I know, the ASAtom value could be returned outside the HANDLER block, but remember that this is a simplified version of the real code.
If the object in nameCos turns out not to be a CosName, CosNameValue throws an error. But because CosNameValue is inside the E_RETURN, the HANDLER frame has already been destructed, so while Acrobat gives an "Expected CosName" error, MyFancyErrorHandler does not get called, and so I did not get the benefit of the code in the fancy error handler that displays the source code file and line number of the error handler that was triggered.
It seems somewhat obvious now, but the code would trigger the error handler properly if I use:
ASAtom returnAtom = CosNameValue(nameCos);
So the moral of the story is be careful what you put inside the E_RETURN statement.