Archived

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

Serializing Exceptions

Is it possible? I can serialize/deserialize regular objects using InputStream and OutputStream, but I cant find an easy way to do this with with Exceptions. What little info I was able to find seemed to say that it is not possible (at least not exposed in the api - obviously they do get serialized somehow) due to the limitations of the Exception type.

Thanks,
Nick

Quick edit: I did find the "writeException" method in OutputStream, which gives me hope, but I dont see a corresponding "readException" in InputStream. I do see a "throwException" but dont know if that is relevant or how it is used.

Comments

  • Ok I probably should have tried this before creating this thread so apologies for the post if this ends up working.

    Perhaps it's as simple as calling InputStream.throwException() on a ByteSeq that contains a UserException that has been written by OutputStream.writeException()?

    If that works, the only remaining question I have is why can we only serialize/deserialize Ice::UserException? Why not Ice::Exception?
  • benoit
    benoit Rennes, France
    Hi,

    Yes, you should use the input stream throwException method to unmarshall the exception and the output stream writeException method to marshall it. Only user exceptions can go "over the wire", local exceptions can't be transmitted over the wire (except a few of them which can be marshalled with the response of a request). See here in the Ice manual for more informations.

    Cheers,
    Benoit.