[Pyobjc-dev] exception handling design pattern
Brought to you by:
ronaldoussoren
|
From: Bill B. <bb...@co...> - 2002-10-16 00:03:30
|
If I implement something like...
def foo(self):
try:
serverAPIVersion = int( versionInfo['currentXmlRpcVersion'] )
serverAppVersion = int( versionInfo['applicationVersion'] )
except KeyError, aKey:
NSException.raise_format_(NSInternalInconsistencyException, " **
%s key not found in getVersionInfo() response>" % aKey)
... and am calling this code from ObjC (i.e. objc->python->objc
exception), I would expect that the raised NSException would be
transparently passed back through to ObjC. That is:
NS_DURING
[instanceOfPythonObject foo];
NS_HANDLER
... handle the raised NSException here ...
NS_ENDHANDLER
This would seem to be consistent with the ObjC implementation pattern.
That is, it wouldn't matter if -foo is implemented in Python or in the
ObjC parent class of the python class, the behavior would be consistent.
Looking at the implementation, it looks like the problem lies in the
behavior of the ObjC->Python part of the bridge in that it leaves the
NSException in a wrapped up state?
I'm not sure how this would influence the relatively complex situation
of, say, ObjC->Python->ObjC->Python->Objc exception raised... I.e. in
the 'ObjC' parts of the stack, you want to raise the exception and let
the next level up's interface between Python->ObjC catch it, convert it
into the appropriate Python exception, then convert it back into an
NSException at the next ObjC->Python extension (keeping in mind that
the exception goes from right to left).
b.bum
|