summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-09-27 15:31:04 +0000
committerMarc Laukien <marc@zeroc.com>2002-09-27 15:31:04 +0000
commit6f9d449ef67cb3d5c3a1778d7c20d0338e2635b6 (patch)
tree9dba8b5850cbf61c8330c3d405b411a1ee5bda18 /cpp/src
parentadded AbortException to IcePatch.ice with support in IcePatch/ClientUtil (diff)
downloadice-6f9d449ef67cb3d5c3a1778d7c20d0338e2635b6.tar.bz2
ice-6f9d449ef67cb3d5c3a1778d7c20d0338e2635b6.tar.xz
ice-6f9d449ef67cb3d5c3a1778d7c20d0338e2635b6.zip
added RequestFailedException
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Exception.cpp50
-rw-r--r--cpp/src/Ice/Incoming.cpp77
-rw-r--r--cpp/src/Ice/Outgoing.cpp59
3 files changed, 94 insertions, 92 deletions
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp
index 7d818ddee6f..fe16488409e 100644
--- a/cpp/src/Ice/Exception.cpp
+++ b/cpp/src/Ice/Exception.cpp
@@ -116,38 +116,56 @@ Ice::LocationForwardIdentityException::ice_print(ostream& out) const
out << ":\nidentity mismatch in location forward";
}
-void
-Ice::ObjectNotExistException::ice_print(ostream& out) const
+static void
+printFailedRequestData(ostream& out, const RequestFailedException& ex)
{
- Exception::ice_print(out);
- out << ":\nobject `" << identityToString(id) << "' does not exist";
-}
-
-void
-Ice::FacetNotExistException::ice_print(ostream& out) const
-{
- Exception::ice_print(out);
- out << ":\nfacet `";
- vector<string>::const_iterator p = facet.begin();
- while(p != facet.end())
+ out << "\nidentity: " << identityToString(ex.id);
+ out << "\nfacet: ";
+ vector<string>::const_iterator p = ex.facet.begin();
+ while(p != ex.facet.end())
{
//
// TODO: Escape for whitespace and slashes.
//
out << *p++;
- if(p != facet.end())
+ if(p != ex.facet.end())
{
out << '/';
}
}
- out << "' does not exist";
+ out << "\noperation: " << ex.operation;
+}
+
+void
+Ice::RequestFailedException::ice_print(ostream& out) const
+{
+ Exception::ice_print(out);
+ out << ":\nrequest failed";
+ printFailedRequestData(out, *this);
+}
+
+void
+Ice::ObjectNotExistException::ice_print(ostream& out) const
+{
+ Exception::ice_print(out);
+ out << ":\nobject does not exist";
+ printFailedRequestData(out, *this);
+}
+
+void
+Ice::FacetNotExistException::ice_print(ostream& out) const
+{
+ Exception::ice_print(out);
+ out << ":\nfacet does not exist";
+ printFailedRequestData(out, *this);
}
void
Ice::OperationNotExistException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\noperation `" << operation << "' does not exist";
+ out << ":\noperation does not exist";
+ printFailedRequestData(out, *this);
}
void
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index 995f90d4085..8e6458aae69 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -132,21 +132,16 @@ IceInternal::Incoming::invoke(bool response)
if(status != DispatchOK && status != DispatchUserException)
{
+ assert(status == DispatchObjectNotExist ||
+ status == DispatchFacetNotExist ||
+ status == DispatchOperationNotExist);
+
_os.b.resize(statusPos);
_os.write(static_cast<Byte>(status));
- if(status == DispatchObjectNotExist)
- {
- current.id.__write(&_os);
- }
- else if(status == DispatchFacetNotExist)
- {
- _os.write(current.facet);
- }
- else if(status == DispatchOperationNotExist)
- {
- _os.write(current.operation);
- }
+ current.id.__write(&_os);
+ _os.write(current.facet);
+ _os.write(current.operation);
}
else
{
@@ -171,7 +166,7 @@ IceInternal::Incoming::invoke(bool response)
_os.write(ex._prx);
}
}
- catch(const ObjectNotExistException& ex)
+ catch(const RequestFailedException& ex)
{
if(locator && servant)
{
@@ -184,51 +179,29 @@ IceInternal::Incoming::invoke(bool response)
{
_os.endWriteEncaps();
_os.b.resize(statusPos);
- _os.write(static_cast<Byte>(DispatchObjectNotExist));
+ if(dynamic_cast<const ObjectNotExistException*>(&ex))
+ {
+ _os.write(static_cast<Byte>(DispatchObjectNotExist));
+ }
+ else if(dynamic_cast<const FacetNotExistException*>(&ex))
+ {
+ _os.write(static_cast<Byte>(DispatchFacetNotExist));
+ }
+ else if(dynamic_cast<const OperationNotExistException*>(&ex))
+ {
+ _os.write(static_cast<Byte>(DispatchOperationNotExist));
+ }
+ else
+ {
+ assert(false);
+ }
+
// Not current.id.__write(_os), so that the identity
// can be overwritten.
ex.id.__write(&_os);
- }
-
- // Rethrow, so that the caller can print a warning.
- ex.ice_throw();
- }
- catch(const FacetNotExistException& ex)
- {
- if(locator && servant)
- {
- assert(_adapter);
- locator->finished(current, servant, cookie);
- }
-
- _is.endReadEncaps();
- if(response)
- {
- _os.endWriteEncaps();
- _os.b.resize(statusPos);
- _os.write(static_cast<Byte>(DispatchFacetNotExist));
// Not _os.write(current.facet), so that the facet can
// be overwritten.
_os.write(ex.facet);
- }
-
- // Rethrow, so that the caller can print a warning.
- ex.ice_throw();
- }
- catch(const OperationNotExistException& ex)
- {
- if(locator && servant)
- {
- assert(_adapter);
- locator->finished(current, servant, cookie);
- }
-
- _is.endReadEncaps();
- if(response)
- {
- _os.endWriteEncaps();
- _os.b.resize(statusPos);
- _os.write(static_cast<Byte>(DispatchOperationNotExist));
// Not _os.write(current.operation), so that the operation
// can be overwritten.
_os.write(ex.operation);
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp
index e5f2dd52318..dd207ca36f7 100644
--- a/cpp/src/Ice/Outgoing.cpp
+++ b/cpp/src/Ice/Outgoing.cpp
@@ -247,41 +247,52 @@ IceInternal::Outgoing::finished(BasicStream& is)
}
case DispatchObjectNotExist:
- {
- _state = StateLocalException;
- // Don't do ex->identity.read(_is), as this operation
- // might throw exceptions. In such case ex would leak.
- Identity ident;
- ident.__read(&_is);
- ObjectNotExistException* ex = new ObjectNotExistException(__FILE__, __LINE__);
- ex->id = ident;
- _exception = auto_ptr<LocalException>(ex);
- break;
- }
-
case DispatchFacetNotExist:
+ case DispatchOperationNotExist:
{
_state = StateLocalException;
// Don't do _is.read(ex->facet), as this operation
// might throw exceptions. In such case ex would leak.
+ Identity ident;
+ ident.__read(&_is);
vector<string> facet;
_is.read(facet);
- FacetNotExistException* ex = new FacetNotExistException(__FILE__, __LINE__);
- ex->facet = facet;
- _exception = auto_ptr<LocalException>(ex);
- break;
- }
-
- case DispatchOperationNotExist:
- {
- _state = StateLocalException;
- // Don't do _is.read(ex->operation), as this operation
- // might throw exceptions. In such case ex would leak.
string operation;
_is.read(operation);
- OperationNotExistException* ex = new OperationNotExistException(__FILE__, __LINE__);
+
+ RequestFailedException* ex;
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchObjectNotExist:
+ {
+ ex = new ObjectNotExistException(__FILE__, __LINE__);
+ break;
+ }
+
+ case DispatchFacetNotExist:
+ {
+ ex = new FacetNotExistException(__FILE__, __LINE__);
+ break;
+ }
+
+ case DispatchOperationNotExist:
+ {
+ ex = new OperationNotExistException(__FILE__, __LINE__);
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ ex->id = ident;
+ ex->facet = facet;
ex->operation = operation;
_exception = auto_ptr<LocalException>(ex);
+
break;
}