Results 1 to 4 of 4

Thread: 'local' user exceptions possible?

  1. #1
    kpfleming's Avatar
    kpfleming is offline Registered User
    Name: Kevin P. Fleming
    Organization: Digium, Inc.
    Project: Asterisk SCF
    Join Date
    Nov 2010
    Posts
    6

    Question 'local' user exceptions possible?

    I suspect this doesn't qualify as a bug, so I'm posting it here instead of the bug forum.

    In our project, we're using Slice to define a set of interfaces for some functionality that will only exist locally (no remote interaction at all), similar to what Ice itself does for Icebox and other services that can be used from an application/component. In this case, Slice is our 'IDL', and we'll build implementations of this functionality in various languages, and consuming developers will have a consistent interface to these mechanisms.

    Now on to the actual problem: in some of our interfaces, we'd like some of the operations to be able to throw exceptions... so we defined them in the Slice file. If the exceptions are defined as 'normal' (not defined as 'local'), the generated C++ code compiles properly, but the exceptions cannot contain 'local' objects (which we want to do to indicate to the caller which specific objects caused the exception to be thrown). If we define the exceptions as 'local', they can contain local objects, but they derive from Ice::LocalException which appears to be for Ice run-time usage only... and worse, the exception declarations include an ice_print() virtual member function, but there is no definition of that function provided.

    I fear that once again we're trying to use Slice in a way that wasn't anticipated... is there a way to do what we want to do?

  2. #2
    kpfleming's Avatar
    kpfleming is offline Registered User
    Name: Kevin P. Fleming
    Organization: Digium, Inc.
    Project: Asterisk SCF
    Join Date
    Nov 2010
    Posts
    6
    Oh, I forgot the details asked for above... we are using Ice 3.4.1, translating Slice to C++, and compiling with GCC 4.4.x on Linux.

  3. #3
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    Hi Kevin,

    If your exception contains local objects, it should be declared as 'local'. This question probably didn't come up before because using local types is unusual.

    In C++ (and only in C++), the generated code for local exceptions declares a function ice_print, but does not generate its implementation. This allows the developer (so far mostly us) to provide an implementation that prints a better error message, using the data members of the exception.

    Unfortunately this behavior is neither optional nor documented... so it's a bug. It would be cleaner to make this feature optional and triggered by metadata, something like:

    Code:
    ["cpp:overwrite_ice_print"]  // C++ generated code will declare ice_print,
                                          // but won't provide its implementation
    local exception MyLocalError
    {
    };
    Would this work well for you?

    Thanks,
    Bernard
    Bernard Normier
    ZeroC, Inc.

  4. #4
    kpfleming's Avatar
    kpfleming is offline Registered User
    Name: Kevin P. Fleming
    Organization: Digium, Inc.
    Project: Asterisk SCF
    Join Date
    Nov 2010
    Posts
    6
    Yes, making the 'ice_print' generation optional would definitely solve the problem.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. User exceptions for AMI?
    By jharriot in forum Help Center
    Replies: 1
    Last Post: 08-20-2010, 06:48 AM
  2. Idempotent and user exceptions
    By Pompei2 in forum Help Center
    Replies: 2
    Last Post: 08-26-2009, 05:39 AM
  3. Glacier2 with other local servers
    By bigtim in forum Help Center
    Replies: 6
    Last Post: 10-05-2007, 12:17 PM
  4. Local interface
    By mwilson in forum Help Center
    Replies: 3
    Last Post: 01-10-2007, 11:22 AM
  5. local exception / C++
    By daniell in forum Bug Reports
    Replies: 7
    Last Post: 11-08-2005, 12:56 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
  •