Archived

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

Catching Custom Exceptions in Ruby

In C++ I throw an ID3::APALException(reason) exception which is declared in my slice file:
module ID3
{
 exception APALException {
  string reason;
 };
...
}

In ruby I catch the exception like this:
begin
 ... # code triggers APALException
rescue => ex
 puts ex.message
 puts ex.backtrace
end

ex.message returns Ice::UnknownUserException, how can I get the correct ID3::APALException object and access the reason?

Comments

  • mes
    mes California
    Hi Peter,

    Two possible reasons for an UnknownUserException are:

    1) You didn't include APALException in the throws clause of your operation.

    2) You didn't load the definition of APALException in your script.

    If you are still having trouble, please describe your environment (Ice version, operating system, Ruby version, etc.), and provide a small example that we can use to reproduce the problem.

    Regards,
    Mark
  • Thanks for your help Mark, 1) was the problem.

    Cheers
    Pete