Home Help Center

A question about Exception hierarchy in Ice

rc_hzrc_hz Member Eric RCOrganization: www.genband.comProject: No project yet ✭✭✭
If an operation implementation raises a run-time exception other than
ObjectNotExistException, FacetNotExistException, or
OperationNotExistException (such as a NotRegisteredException), the
client receives an UnknownLocalException. In other words, the Ice protocol
does not transmit the exact exception that was encountered in the server, but
simply returns a bit to the client in the reply to indicate that the server encountered
a run-time exception.

Suppose an operation throws an CompressionNotSupportedException on the server side, then the client will get an UnknownLocalException and know nothing about CompressionNotSupportedException.

My suggestion:
Since every exception has an unique name(eg. CompressionNotSupportedException's name is "Ice::CompressionNotSupportedException"), it's better that if we can transfer this information to the client. It needs little change to Ice:
//Exception.cpp	
class ICE_UTIL_API Exception
{
	//...
public:
	void ice_setRealName(const char* realName)
	{
		  _realName = realName;
	}  

	char * ice_getRealName()
	{
		  return _realName;
	}  	
private:    
    const char* _realName;
};
	
//Incoming.cpp
    before we replace CompressionNotSupportedException(ex_1) with UnknownLocalException(ex_2), we can do like this:
    ex_2.ice_realName(ex_1.ice_name());

//Client.cpp
//...
try
{
	thePrx->theOperation(...);
}
catch {const UnknownLocalException& ex)
{
	cout << "The exception " << ex.ice_getRealName() << " is caught" << endl;
}
//...
	

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    If you take a closer look at the definition of Ice::UnknownException (in Ice-2.1.1/slice/Ice/LocalException.ice), we actually transfer the stringified representation of the exception in the "unknown" field.

    Benoit.
  • rc_hzrc_hz Member Eric RCOrganization: www.genband.comProject: No project yet ✭✭✭
    Great :p , Thank you!
Sign In or Register to comment.