diff options
author | Marc Laukien <marc@zeroc.com> | 2002-12-07 22:17:44 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-12-07 22:17:44 +0000 |
commit | bec87e9b6a7edcbbfce5fadb520c41816143a8be (patch) | |
tree | d428b8bf9306090d456b198c87d34e0dd048a5cb /cpp/src | |
parent | AMD exception cleanup (diff) | |
download | ice-bec87e9b6a7edcbbfce5fadb520c41816143a8be.tar.bz2 ice-bec87e9b6a7edcbbfce5fadb520c41816143a8be.tar.xz ice-bec87e9b6a7edcbbfce5fadb520c41816143a8be.zip |
more AMD exception fixes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/IncomingAsync.cpp | 144 | ||||
-rw-r--r-- | cpp/src/Ice/Object.cpp | 17 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 33 |
3 files changed, 111 insertions, 83 deletions
diff --git a/cpp/src/Ice/IncomingAsync.cpp b/cpp/src/Ice/IncomingAsync.cpp index 3ae55e0d4d4..a6e1559c5ee 100644 --- a/cpp/src/Ice/IncomingAsync.cpp +++ b/cpp/src/Ice/IncomingAsync.cpp @@ -82,6 +82,21 @@ IceInternal::IncomingAsync::__exception(const Exception& exc) { finishInvoke(); + if(ex.id.name.empty()) + { + ex.id = _current.id; + } + + if(ex.facet.empty() && !_current.facet.empty()) + { + ex.facet = _current.facet; + } + + if(ex.operation.empty() && !_current.operation.empty()) + { + ex.operation = _current.operation; + } + if(_connection) // Response expected? { _os.endWriteEncaps(); @@ -102,64 +117,12 @@ IceInternal::IncomingAsync::__exception(const Exception& exc) { assert(false); } - - // - // Write the data from the exception if set so that a - // RequestFailedException can override the information - // from _current. - // - if(!ex.id.name.empty()) - { - ex.id.__write(&_os); - } - else - { - _current.id.__write(&_os); - } - - if(!ex.facet.empty()) - { - _os.write(ex.facet); - } - else - { - _os.write(_current.facet); - } - - if(ex.operation.empty()) - { - _os.write(ex.operation); - } - else - { - _os.write(_current.operation); - } + ex.id.__write(&_os); + _os.write(ex.facet); + _os.write(ex.operation); _connection->sendResponse(&_os, _compress); } - -/* - if(_instance->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1) - { - if(ex.id.name.empty()) - { - ex.id = _current.id; - } - - if(ex.facet.empty() && !_current.facet.empty()) - { - ex.facet = _current.facet; - } - - if(ex.operation.empty() && !_current.operation.empty()) - { - ex.operation = _current.operation; - } - - Warning out(_instance->logger()); - out << "dispatch exception:\n" << ex; - } -*/ } catch(const LocalException& ex) { @@ -176,14 +139,6 @@ IceInternal::IncomingAsync::__exception(const Exception& exc) _connection->sendResponse(&_os, _compress); } -/* - if(_instance->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - ostringstream str; - str << ex; - warning("dispatch exception: unknown local exception:", str.str()); - } -*/ } catch(const UserException& ex) { @@ -200,15 +155,6 @@ IceInternal::IncomingAsync::__exception(const Exception& exc) _connection->sendResponse(&_os, _compress); } - -/* - if(_instance->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - ostringstream str; - str << ex; - warning("dispatch exception: unknown user exception:", str.str()); - } -*/ } catch(const Exception& ex) { @@ -225,15 +171,39 @@ IceInternal::IncomingAsync::__exception(const Exception& exc) _connection->sendResponse(&_os, _compress); } + } +} -/* - if(_instance->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - ostringstream str; - str << ex; - warning("dispatch exception: unknown exception:", str.str()); - } -*/ +void +IceInternal::IncomingAsync::__exception(const std::exception& ex) +{ + finishInvoke(); + + if(_connection) // Response expected? + { + _os.endWriteEncaps(); + _os.b.resize(headerSize + 4); // Dispatch status position. + _os.write(static_cast<Byte>(DispatchUnknownException)); + ostringstream str; + str << "std::exception: " << ex.what(); + _os.write(str.str()); + + _connection->sendResponse(&_os, _compress); + } +} + +void +IceInternal::IncomingAsync::__exception() +{ + if(_connection) // Response expected? + { + _os.endWriteEncaps(); + _os.b.resize(headerSize + 4); // Dispatch status position. + _os.write(static_cast<Byte>(DispatchUnknownException)); + string reason = "unknown c++ exception"; + _os.write(reason); + + _connection->sendResponse(&_os, _compress); } } @@ -293,7 +263,7 @@ IceAsync::Ice::AMD_Object_ice_invoke::ice_response(bool ok, const ::std::vector< } catch(const LocalException& ex) { - ice_exception(ex); + __exception(ex); return; } @@ -305,3 +275,15 @@ IceAsync::Ice::AMD_Object_ice_invoke::ice_exception(const Exception& ex) { __exception(ex); } + +void +IceAsync::Ice::AMD_Object_ice_invoke::ice_exception(const std::exception& ex) +{ + __exception(ex); +} + +void +IceAsync::Ice::AMD_Object_ice_invoke::ice_exception() +{ + __exception(); +} diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index 14a7e935296..ac3448c8b7a 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -437,6 +437,21 @@ Ice::BlobjectAsync::__dispatch(Incoming& in, const Current& current) Int sz = in.is()->getReadEncapsSize(); in.is()->readBlob(inParams, sz); AMD_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Object_ice_invoke(in); - ice_invoke_async(cb, inParams, current); + try + { + ice_invoke_async(cb, inParams, current); + } + catch(const Exception& ex) + { + cb->ice_exception(ex); + } + catch(const ::std::exception& ex) + { + cb->ice_exception(ex); + } + catch(...) + { + cb->ice_exception(); + } return ::IceInternal::DispatchOK; } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 24beb414196..c7ecc516a3f 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -2528,7 +2528,22 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) writeUnmarshalCode(C, inParams, 0); C << nl << classScopedAMD << '_' << name << "Ptr __cb = new ::IceAsync" << classScopedAMD << '_' << name << "(__in);"; + C << nl << "try"; + C << sb; C << nl << name << "_async" << argsAMD << ';'; + C << eb; + C << nl << "catch(const ::Ice::Exception& __ex)"; + C << sb; + C << nl << "__cb->ice_exception(__ex);"; + C << eb; + C << nl << "catch(const ::std::exception& __ex)"; + C << sb; + C << nl << "__cb->ice_exception(__ex);"; + C << eb; + C << nl << "catch(...)"; + C << sb; + C << nl << "__cb->ice_exception();"; + C << eb; C << nl << "return ::IceInternal::DispatchOK;"; } C << eb; @@ -3384,6 +3399,8 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) H << sp; H << nl << "virtual void ice_response(" << params << ") = 0;"; H << nl << "virtual void ice_exception(const ::Ice::Exception&) = 0;"; + H << nl << "virtual void ice_exception(const ::std::exception&) = 0;"; + H << nl << "virtual void ice_exception() = 0;"; H << eb << ';'; H << sp << nl << "typedef ::IceUtil::Handle< " << classScopedAMD << '_' << name << "> " << classNameAMD << '_' << name << "Ptr;"; @@ -3515,6 +3532,8 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) H << sp; H << nl << "virtual void ice_response(" << params << ");"; H << nl << "virtual void ice_exception(const ::Ice::Exception&);"; + H << nl << "virtual void ice_exception(const ::std::exception&);"; + H << nl << "virtual void ice_exception();"; H << eb << ';'; C << sp << nl << "::IceAsync" << classScopedAMD << '_' << name << "::" << classNameAMD << '_' << name @@ -3537,7 +3556,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << eb; C << nl << "catch(const ::Ice::Exception& __ex)"; C << sb; - C << nl << "ice_exception(__ex);"; + C << nl << "__exception(__ex);"; C << nl << "return;"; C << eb; } @@ -3572,5 +3591,17 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << eb; } C << eb; + + C << sp << nl << "void" << nl << "::IceAsync" << classScopedAMD << '_' << name + << "::ice_exception(const ::std::exception& ex)"; + C << sb; + C << nl << "__exception(ex);"; + C << eb; + + C << sp << nl << "void" << nl << "::IceAsync" << classScopedAMD << '_' << name + << "::ice_exception()"; + C << sb; + C << nl << "__exception();"; + C << eb; } } |