Abstracting exception checking?

The simplest solution would be to pass your code to a method as a block and yield to it within a begin/rescue expression: def run_code_and_handle_exceptions begin yield rescue 1... rescue 2... rescue 3... rescue 4... end end # Elsewhere... def a run_code_and_handle_exceptions do code end end # etc You may want to come up with a more succinct method name than run_code_and_handle_exceptions!

The simplest solution would be to pass your code to a method as a block and yield to it within a begin/rescue expression: def run_code_and_handle_exceptions begin yield rescue 1... rescue 2... rescue 3... rescue 4... end end # Elsewhere... def a run_code_and_handle_exceptions do code end end # etc... You may want to come up with a more succinct method name than run_code_and_handle_exceptions!

In controllers I've used rescue_from -functionality. It's quite DRY: class WorldController :handle_unfound_record def handle_unfound_record # Exception handling... end.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions