Brian Hartin
4/1/2008 5:21:00 PM
I could not find any information about this, except regarding DRb.
It seems like the raise method / Exception class ought to allow me to
pass in a 'causal' exception, e.g.
begin
=20 foo
rescue Exception =3D> e
=20 raise ServiceNotFoundException, "The service could not be contacted",=
e
end
This doesn't work. I can, however, pass in the backtrace, e.g.
raise ServiceNotFoundException, "The service could not be contacted",
e.backtrace
However, doing this I get the stack trace but not the type or message
from the causal exception (unless I manually put them in the message
string). Ideally, I'd be able to use exception chaining such as in
Java, in which my stack traces include causal exceptions:
WebServiceCommunicationException: The WSDL could not be obtained from
http://blah/wsdl.
=20 from (webservice_client.rb):123:in `obtain_wsdl'
=20 from (webservice_client.rb):12:in `request_price'
caused by ParsingError: Unexpected element 'html'
=20 from (other_class.rb):234 in 'some_method'
=20 from (other_class.rb):23 in 'some_other_method'
=20 ...
including a 'cause' field on the Exception class, e.g. e.cause.
Is there some reason why this would not fit the Ruby style? If not, is
this something that would be considered as a patch/change for Ruby?
I realize I could probably monkeypatch Exception, but this seems (to me)
like it would be an improvement to the language.
Thanks,
Brian Hartin
*************************************************************************=
***=20
This email may contain material confidential to
Pearson. If you were not an intended recipient,=20
please notify the sender and delete all copies.=20
We may monitor email to and from our network.=20
*************************************************************************=
***