diff options
author | Benoit Foucher <benoit@zeroc.com> | 2011-04-07 10:06:35 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2011-04-07 10:06:35 +0200 |
commit | 882f85bfb8d6158adffbf6024c9a029ea0b13d63 (patch) | |
tree | 63a04bae891b7cbc3491710c6bf712972563084b /py/modules/IcePy/Operation.cpp | |
parent | Added CHANGES entry for previous bug fix (diff) | |
download | ice-882f85bfb8d6158adffbf6024c9a029ea0b13d63.tar.bz2 ice-882f85bfb8d6158adffbf6024c9a029ea0b13d63.tar.xz ice-882f85bfb8d6158adffbf6024c9a029ea0b13d63.zip |
Bug 4720 - Improved AsyncResult to allow throwing local exception is request failed with local exception
Diffstat (limited to 'py/modules/IcePy/Operation.cpp')
-rw-r--r-- | py/modules/IcePy/Operation.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp index 8c7b4bf33c9..71a081e6e7c 100644 --- a/py/modules/IcePy/Operation.cpp +++ b/py/modules/IcePy/Operation.cpp @@ -887,6 +887,31 @@ asyncResultWaitForSent(AsyncResultObject* self) extern "C" #endif static PyObject* +asyncResultThrowLocalException(AsyncResultObject* self) +{ + try + { + assert(self->result); + (*self->result)->throwLocalException(); + } + catch(const Ice::LocalException& ex) + { + setPythonException(ex); + return 0; + } + catch(...) + { + assert(false); + } + + Py_INCREF(Py_None); + return Py_None; +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* asyncResultSentSynchronously(AsyncResultObject* self) { bool b = false; @@ -1121,6 +1146,8 @@ static PyMethodDef AsyncResultMethods[] = PyDoc_STR(STRCAST("returns true if the request is sent")) }, { STRCAST("waitForSent"), reinterpret_cast<PyCFunction>(asyncResultWaitForSent), METH_NOARGS, PyDoc_STR(STRCAST("blocks until the request is sent")) }, + { STRCAST("throwLocalException"), reinterpret_cast<PyCFunction>(asyncResultThrowLocalException), METH_NOARGS, + PyDoc_STR(STRCAST("throw location exception if the request failed with a local exception")) }, { STRCAST("sentSynchronously"), reinterpret_cast<PyCFunction>(asyncResultSentSynchronously), METH_NOARGS, PyDoc_STR(STRCAST("returns true if the request was sent synchronously")) }, { STRCAST("getOperation"), reinterpret_cast<PyCFunction>(asyncResultGetOperation), METH_NOARGS, |