Results 1 to 5 of 5

Thread: Python UnexpectedObjectException has incorrect details

  1. #1
    GaryD is offline Registered User
    Name: Gary Donovan
    Organization: Crucial Fruit
    Project: CRM for charities
    Join Date
    Mar 2009
    Location
    Australia
    Posts
    25

    Python UnexpectedObjectException has incorrect details

    In my python code, I have written an Ice.ObjectFactory subclass to create instances of an ICE class I am using. I stuffed up and returned the wrong type, and got this exception:

    Ice.UnexpectedObjectException: exception ::Ice::UnexpectedObjectException
    {
    reason = unmarshaled object is not an instance of ::Basket::Entities::Entity
    GroupData
    type = ::Basket::Entities::EntityGroupData
    expectedType = ::Basket::Entities::EntityGroupData
    }

    Obviously I need to fix my class factory :-)

    However, I also suspect that the `type' parameter of the Ice.UnexpectedObjectException is wrong. Shouldn't it be "::Basket::Entities::BaseEntityData" (ie. the type of the object I actually returned from my class factory) rather than "::Basket::Entities::EntityGroupData" (ie. the type of the object I should have returned)? Or is there some other subtlety here that I am not aware of?

    Cheers,
    garyD!

  2. #2
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Hi Gary,

    You're right, the type member should show the actual type of the object. Unfortunately, I can't reproduce this behavior. Do you have a small test case? Also, can you describe your environment (OS, Python version, Ice version, etc.)?

    Thanks,
    Mark

  3. #3
    GaryD is offline Registered User
    Name: Gary Donovan
    Organization: Crucial Fruit
    Project: CRM for charities
    Join Date
    Mar 2009
    Location
    Australia
    Posts
    25
    Sorry - environment details are:
    * Windows XP Pro SP3
    * Python v2.6.1
    * ICE v3.3.1

    The situation is that I have (ICE) class B extends class A, and class C extends class A. My factory returned an instance of B instead of C.

    I will try to work up a simple example for you.

    cheers,
    gary

  4. #4
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Thanks Gary, but I don't think I'll need a test case after all.

    If your factory incorrectly returns an object that is not of the expected type, it would explain the bogus type member in the exception. The Ice run time assumes that when it asks a factory for an object of a certain type, the factory will actually return an instance of that type.

    Regards,
    Mark

  5. #5
    GaryD is offline Registered User
    Name: Gary Donovan
    Organization: Crucial Fruit
    Project: CRM for charities
    Join Date
    Mar 2009
    Location
    Australia
    Posts
    25
    Okay, I just had a look at your source code, and I see what you mean. When UnexpectedObjectException gets thrown (in IcePy::ReadObjectCallback::invoke) we have to use the ID from the reader, rather than trying to infer it from an arbitrary python object (that may not have an ID).

    So an enhancement might be to check the return value from a factory and provide a more specific error message, but that's probably not very important (I know I am not motivated to go and write it :-).

    Thanks,
    gary

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. FAQ contains incorrect code?
    By oliverk in forum Help Center
    Replies: 1
    Last Post: 04-20-2010, 04:59 PM
  2. IcePy segfaults on incorrect router configuration
    By vsevolod in forum Bug Reports
    Replies: 1
    Last Post: 10-27-2009, 11:29 AM
  3. Passing SSL connection details to application
    By kwaclaw in forum Comments
    Replies: 4
    Last Post: 10-04-2005, 03:24 PM
  4. Replies: 1
    Last Post: 11-28-2003, 03:11 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
  •