From: Brian Hartin Date: 2008-04-03T03:45:01+09:00 Subject: Re: Does Ruby support exception wrapping (exception chaining Joel, This doesn't really provide the main benefit to exception wrapping mechanism: the ability to wrap low-level exceptions in an appropriate higher-level exception and yet not lose the entire stack trace, or the types and messages of the low-level exceptions. Exception wrapping (a.k.a. chaining) in Java (a good model for this feature, I think) makes the idea of a 'causal Exception' part of the class (via a 'cause' field), and the stack trace: an Exception's stack trace includes the causal 'chain' of Exceptions automatically. I think I can write this up for my own use. I just wondered if I was missing an existing feature. Thanks for the response! Joel VanderWerf wrote: > Hartin, Brian wrote: >> end > The second arg to raise (i.e. the message) can be any object: > > class ServiceNotFoundException < StandardError; end > > begin > begin > raise "foo" > rescue Exception => e > raise ServiceNotFoundException, ["The service could not be > contacted", > e] > end > rescue Exception => e_outer > puts e_outer > p e_outer.message > end > > __END__ > > Output: > > # > ["The service could not be contacted", #] -- Posted via http://www.ruby-forum.com/.