Results 1 to 3 of 3

Thread: A question about Exception hierarchy in Ice

  1. #1
    rc_hz is offline Registered User
    Name: Eric RC
    Organization: www.genband.com
    Project: No project yet
    Join Date
    Jul 2004
    Location
    Hangzhou, China
    Posts
    189

    A question about Exception hierarchy in Ice

    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:

    Code:
    //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;
    }
    //...
    Last edited by rc_hz; 06-15-2005 at 03:38 AM.
    Eric RC
    www.genband.com (telecommunication)
    I like ICE (Ice for C++/Java/Python)

  2. #2
    benoit's Avatar
    benoit is online now ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    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.

  3. #3
    rc_hz is offline Registered User
    Name: Eric RC
    Organization: www.genband.com
    Project: No project yet
    Join Date
    Jul 2004
    Location
    Hangzhou, China
    Posts
    189
    Great , Thank you!
    Eric RC
    www.genband.com (telecommunication)
    I like ICE (Ice for C++/Java/Python)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 02-22-2011, 01:54 PM
  2. Exception throwing question
    By g00fy in forum Help Center
    Replies: 2
    Last Post: 06-28-2006, 07:40 PM
  3. Question about slice and exception.
    By OrNot in forum Help Center
    Replies: 6
    Last Post: 10-22-2005, 12:07 AM
  4. problem aboiut stream hierarchy
    By rc_hz in forum Comments
    Replies: 2
    Last Post: 05-25-2005, 04:15 AM
  5. Bad alloc exception question
    By stephan in forum Bug Reports
    Replies: 1
    Last Post: 12-26-2004, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •