Archived

This forum has been archived. Please start a new discussion on GitHub.

User exceptions for AMI?

Hi,

Configuration: Ice=3.3.1, VS2009, WinXP, Language C#

I have created a user exception in the Ice file.

exception TickError;
["ami"] void Tick() throws TickError;


The server side code throws a TickError exception and the argument for TickError is a custom .net exception


void Tick(Ice.Current current__)
{
try
{
... blah

throw new CustomException("My message");

... blah
}
catch (CustomException ex)
{
throw new TickError(ex);
}
}


The client side implements the ice_exception(Ice.Exception ex) method. However I cannot obtain the message that was used to create CustomException. The Message field of the exception received by ice_exception() contains the type of message, eg ex.Message = SDS.Slice.TickError.

Comments

  • Problem solved

    I modified the Ice async example code and the following approach appears to work.

    Slice file:
    exception RequestCanceledException
    {
       string reason;
    }
    


    Server side:
    entry.cb.ice_exception(new RequestCanceledException("hi there"));
    

    Client side:
    public override void ice_exception(Ice.Exception ex)
    {
          try
          {
              throw ex;
          }
          catch (RequestCanceledException ex1)
          {
               Console.Error.WriteLine("Error: {0}", ex1.reason);
          }
    }