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
foo
rescue Exception => e
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.
from (webservice_client.rb):123:in obtain_wsdl' from (webservice_client.rb):12:in
request_price’
caused by ParsingError: Unexpected element ‘html’
from (other_class.rb):234 in ‘some_method’
from (other_class.rb):23 in ‘some_other_method’
…
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 H.
This email may contain material confidential to
Pearson. If you were not an intended recipient,
please notify the sender and delete all copies.
We may monitor email to and from our network.