diff options
author | Mark Spruiell <mes@zeroc.com> | 2009-02-02 16:45:19 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2009-02-02 16:45:19 -0800 |
commit | eddc5e979d7c65f0d1513b7c2966414d31b2ffcf (patch) | |
tree | c8e0283927ddcb395d09ec7cacab2114ba232cae /py/modules/IcePy/Operation.cpp | |
parent | bug 3644 - improve integration between eclipse plugin and translator (diff) | |
download | ice-eddc5e979d7c65f0d1513b7c2966414d31b2ffcf.tar.bz2 ice-eddc5e979d7c65f0d1513b7c2966414d31b2ffcf.tar.xz ice-eddc5e979d7c65f0d1513b7c2966414d31b2ffcf.zip |
- Implementing Ice.Trace.Slicing in Python & Ruby
- Improving UnmarshalOutOfBoundsException for unknown exceptions
Diffstat (limited to 'py/modules/IcePy/Operation.cpp')
-rw-r--r-- | py/modules/IcePy/Operation.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp index 9dfaf051504..d039c1fd3e2 100644 --- a/py/modules/IcePy/Operation.cpp +++ b/py/modules/IcePy/Operation.cpp @@ -19,8 +19,10 @@ #include <Ice/IncomingAsync.h> #include <Ice/Initialize.h> #include <Ice/LocalException.h> +#include <Ice/Logger.h> #include <Ice/ObjectAdapter.h> #include <Ice/OutgoingAsync.h> +#include <Ice/Properties.h> #include <Ice/Proxy.h> #include <Slice/PythonUtil.h> @@ -950,11 +952,15 @@ IcePy::TypedInvocation::unmarshalResults(const pair<const Ice::Byte*, const Ice: PyObject* IcePy::TypedInvocation::unmarshalException(const pair<const Ice::Byte*, const Ice::Byte*>& bytes) { + int traceSlicing = -1; + Ice::InputStreamPtr is = Ice::createInputStream(_communicator, bytes); is->readBool(); // usesClasses string id = is->readString(); + const string origId = id; + while(!id.empty()) { ExceptionInfoPtr info = lookupExceptionInfo(id); @@ -978,18 +984,41 @@ IcePy::TypedInvocation::unmarshalException(const pair<const Ice::Byte*, const Ic } else { - is->skipSlice(); - id = is->readString(); + if(traceSlicing == -1) + { + traceSlicing = _communicator->getProperties()->getPropertyAsInt("Ice.Trace.Slicing") > 0; + } + + if(traceSlicing > 0) + { + _communicator->getLogger()->trace("Slicing", "unknown exception type `" + id + "'"); + } + + is->skipSlice(); // Slice off what we don't understand. + + try + { + id = is->readString(); // Read type id for next slice. + } + catch(Ice::UnmarshalOutOfBoundsException& ex) + { + // + // When readString raises this exception it means we've seen the last slice, + // so we set the reason member to a more helpful message. + // + ex.reason = "unknown exception type `" + origId + "'"; + throw; + } } } // // Getting here should be impossible: we can get here only if the // sender has marshaled a sequence of type IDs, none of which we - // have factory for. This means that sender and receiver disagree + // have a factory for. This means that sender and receiver disagree // about the Slice definitions they use. // - throw Ice::UnknownUserException(__FILE__, __LINE__); + throw Ice::UnknownUserException(__FILE__, __LINE__, "unknown exception type `" + origId + "'"); } bool |