From: yermej Date: 2007-11-08T04:15:53+09:00 Subject: Re: Rambling: try/catch On Nov 7, 12:40 pm, Casimir P wrote: > Just had an vague idea about generic java "try-catch" converted to ruby- > world I would like some feedback on. > > I'm building a "microscopic CMS" system to learn more ruby, and of course > it would be good to implement proper error catching system. Try-catch is > what java uses. > > Now the vague idea was to create one error catching function, and to > throw all things that might fail (say loading a file) "through" that > function. Passed as a code block? I am not sure, it keeps slipping from > me. :) > > What do you think? > > -- > Casimir Pohjanraito > Art Portfolio:http://csmr.dreamhosters.com I'm not sure I completely understand (I've had a string of wrong answers here recently), but I think you're looking for begin/rescue: begin do_something_that_might_explode() rescue => e puts "uh-oh, an exception: #{e}: #{e.backtrace.join("\n")}" end