From: Wirianto Djunaidi Date: 2008-01-11T07:53:07+09:00 Subject: Re: Execution stops once exception is fired Mauricio Gonzales wrote: > Clifford Heath wrote: > >> Mauricio Gonzales wrote: >> >>> object.method3() >>> rescue => e >>> puts e >>> end >>> >>> and never executes the method3() >>> >> That's the way it's meant to work, it's just what exceptions are, >> non-local "goto"s to a handler. If you want method3 always to be >> called, put it in a "finally" clause. >> >> Clifford Heath. >> > That's probably will be a solution but the problem is that i don't know > when the exception is raised and neither in what method or how many > methods will be, well thx anyway for your help, cya > > If that is the behavior that you wanted, then you will need to wrap each method call in begin..rescue block individually. One way to do it just create a wrapper method to reduce verbosity, like this: def wrapper(&block) begin block.call rescue => e puts e end end wrapper { object.method1 } wrapper { object.method2 } wrapper { object.method3 } I'm sure there are many other way to achieve the same things, such as using more advance metaprogramming which I'm still not at that level yet or use aspect oriented technique. -DJ