summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2007-06-20 11:09:54 -0230
committerDwayne Boone <dwayne@zeroc.com>2007-06-20 11:09:54 -0230
commite2ca0b3550347f37113569571dede1aae48922b9 (patch)
treee8c85dd8c92d8d70b9bbddf3a5ce415522980fcf /cpp/src
parentMerge branch 'master' of ssh://cvs.zeroc.com/home/git/ice (diff)
downloadice-e2ca0b3550347f37113569571dede1aae48922b9.tar.bz2
ice-e2ca0b3550347f37113569571dede1aae48922b9.tar.xz
ice-e2ca0b3550347f37113569571dede1aae48922b9.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=2140
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Application.cpp2
-rw-r--r--cpp/src/Ice/Incoming.cpp194
-rw-r--r--cpp/src/slice2cpp/Gen.cpp20
3 files changed, 73 insertions, 143 deletions
diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp
index bb5b16588e1..cc6d1f39e39 100644
--- a/cpp/src/Ice/Application.cpp
+++ b/cpp/src/Ice/Application.cpp
@@ -124,7 +124,7 @@ destroyOnInterruptCallback(int signal)
catch(const std::exception& ex)
{
cerr << _appName << " (while destroying in response to signal " << signal
- << "): std::exception: " << ex.what() << endl;
+ << "): " << ex.what() << endl;
}
catch(const std::string& msg)
{
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index f1ac54bd083..391515df1ad 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -92,47 +92,46 @@ IceInternal::IncomingBase::__warning(const string& msg) const
}
void
-IceInternal::IncomingBase::__handleException(const std::exception& ex)
+IceInternal::IncomingBase::__handleException(const std::exception& exc)
{
- try
- {
- throw ex;
- }
- catch(RequestFailedException& ex)
+ if(dynamic_cast<const RequestFailedException*>(&exc))
{
- if(ex.id.name.empty())
+ RequestFailedException* rfe =
+ const_cast<RequestFailedException*>(dynamic_cast<const RequestFailedException*>(&exc));
+
+ if(rfe->id.name.empty())
{
- ex.id = _current.id;
+ rfe->id = _current.id;
}
- if(ex.facet.empty() && !_current.facet.empty())
+ if(rfe->facet.empty() && !_current.facet.empty())
{
- ex.facet = _current.facet;
+ rfe->facet = _current.facet;
}
- if(ex.operation.empty() && !_current.operation.empty())
+ if(rfe->operation.empty() && !_current.operation.empty())
{
- ex.operation = _current.operation;
+ rfe->operation = _current.operation;
}
if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
{
- __warning(ex);
+ __warning(*rfe);
}
if(_response)
{
_os.endWriteEncaps();
_os.b.resize(headerSize + 4); // Reply status position.
- if(dynamic_cast<ObjectNotExistException*>(&ex))
+ if(dynamic_cast<ObjectNotExistException*>(rfe))
{
_os.write(replyObjectNotExist);
}
- else if(dynamic_cast<FacetNotExistException*>(&ex))
+ else if(dynamic_cast<FacetNotExistException*>(rfe))
{
_os.write(replyFacetNotExist);
}
- else if(dynamic_cast<OperationNotExistException*>(&ex))
+ else if(dynamic_cast<OperationNotExistException*>(rfe))
{
_os.write(replyOperationNotExist);
}
@@ -141,21 +140,21 @@ IceInternal::IncomingBase::__handleException(const std::exception& ex)
assert(false);
}
- ex.id.__write(&_os);
+ rfe->id.__write(&_os);
//
// For compatibility with the old FacetPath.
//
- if(ex.facet.empty())
+ if(rfe->facet.empty())
{
_os.write(static_cast<string*>(0), static_cast<string*>(0));
}
else
{
- _os.write(&ex.facet, &ex.facet + 1);
+ _os.write(&rfe->facet, &rfe->facet + 1);
}
- _os.write(ex.operation, false);
+ _os.write(rfe->operation, false);
_connection->sendResponse(&_os, _compress);
}
@@ -164,125 +163,54 @@ IceInternal::IncomingBase::__handleException(const std::exception& ex)
_connection->sendNoResponse();
}
}
- catch(const UnknownLocalException& ex)
- {
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Reply status position.
- _os.write(replyUnknownLocalException);
- _os.write(ex.unknown, false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
- }
- catch(const UnknownUserException& ex)
- {
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Reply status position.
- _os.write(replyUnknownUserException);
- _os.write(ex.unknown, false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
- }
- catch(const UnknownException& ex)
- {
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Reply status position.
- _os.write(replyUnknownException);
- _os.write(ex.unknown, false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
- }
- catch(const LocalException& ex)
- {
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Reply status position.
- _os.write(replyUnknownLocalException);
- ostringstream str;
- str << ex;
- _os.write(str.str(), false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
- }
- catch(const UserException& ex)
- {
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Reply status position.
- _os.write(replyUnknownUserException);
- ostringstream str;
- str << ex;
- _os.write(str.str(), false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
- }
- catch(const Exception& ex)
+ else if(const Exception* ex = dynamic_cast<const Exception*>(&exc))
{
+
if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- __warning(ex);
+ __warning(*ex);
}
if(_response)
{
_os.endWriteEncaps();
_os.b.resize(headerSize + 4); // Reply status position.
- _os.write(replyUnknownException);
- ostringstream str;
- str << ex;
- _os.write(str.str(), false);
+ if(const UnknownLocalException* ule = dynamic_cast<const UnknownLocalException*>(&exc))
+ {
+ _os.write(replyUnknownLocalException);
+ _os.write(ule->unknown, false);
+ }
+ else if(const UnknownUserException* uue = dynamic_cast<const UnknownUserException*>(&exc))
+ {
+ _os.write(replyUnknownUserException);
+ _os.write(uue->unknown, false);
+ }
+ else if(const UnknownException* ue = dynamic_cast<const UnknownException*>(&exc))
+ {
+ _os.write(replyUnknownException);
+ _os.write(ue->unknown, false);
+ }
+ else if(const LocalException* le = dynamic_cast<const LocalException*>(&exc))
+ {
+ _os.write(replyUnknownLocalException);
+ ostringstream str;
+ str << *le;
+ _os.write(str.str(), false);
+ }
+ else if(const UserException* ue = dynamic_cast<const UserException*>(&exc))
+ {
+ _os.write(replyUnknownUserException);
+ ostringstream str;
+ str << *ue;
+ _os.write(str.str(), false);
+ }
+ else
+ {
+ _os.write(replyUnknownException);
+ ostringstream str;
+ str << *ex;
+ _os.write(str.str(), false);
+ }
_connection->sendResponse(&_os, _compress);
}
else
@@ -290,11 +218,11 @@ IceInternal::IncomingBase::__handleException(const std::exception& ex)
_connection->sendNoResponse();
}
}
- catch(const std::exception& ex)
+ else
{
if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- __warning(string("std::exception: ") + ex.what());
+ __warning(string("std::exception: ") + exc.what());
}
if(_response)
@@ -303,7 +231,7 @@ IceInternal::IncomingBase::__handleException(const std::exception& ex)
_os.b.resize(headerSize + 4); // Reply status position.
_os.write(replyUnknownException);
ostringstream str;
- str << "std::exception: " << ex.what();
+ str << "std::exception: " << exc.what();
_os.write(str.str(), false);
_connection->sendResponse(&_os, _compress);
}
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index da5f91bbb8e..ec7b3e7d23e 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -5126,27 +5126,29 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
}
else
{
- C << nl << "try";
- C << sb;
- C << nl << "throw ex;";
- C << eb;
ExceptionList::const_iterator r;
for(r = throws.begin(); r != throws.end(); ++r)
{
- C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)";
+ C << nl;
+ if(r != throws.begin())
+ {
+ C << "else ";
+ }
+ C << "if(const " << fixKwd((*r)->scoped()) << "* __ex = dynamic_cast<const " << fixKwd((*r)->scoped())
+ << "*>(&ex))";
C << sb;
C << nl <<"if(__validateResponse(false))";
C << sb;
- C << nl << "__os()->write(__ex);";
+ C << nl << "__os()->write(*__ex);";
C << nl << "__response(false);";
C << eb;
C << eb;
}
- C << nl << "catch(const ::std::exception& __ex)";
+ C << nl << "else";
C << sb;
- C << nl << "if(__validateException(__ex))";
+ C << nl << "if(__validateException(ex))";
C << sb;
- C << nl << "__exception(__ex);";
+ C << nl << "__exception(ex);";
C << eb;
C << eb;
}