From: Martin Hansen Date: 2010-08-06T17:26:55+09:00 Subject: Re: Abstracting exception handling I have been looking at your suggestions and done a few tests. However, I wonder if there is not a more simple way - and especially since these suggestions depends on methods being defined in order to invoke error handling. Here is a real life example of the type of minimalistic scripts I want to write: #!/usr/bin/env ruby require 'biopieces' casts = [] casts << {:long=>'compress',:short=>'Z',:type=>'flag',:mandatory=>false,:default=>nil,:allowed=>nil,:disallowed=>nil} bp = Biopieces.new options = bp.parse(ARGV,casts) bp.mktmpdir # create an optional temporary directory that is auto deleted. bp.each_record do |record| # do something to each record (possibly according to the options). e.g.: record["SEQ"].upcase! if record.has_key? "SEQ" bp.puts record raise # Debug test of invokation of error handling end Now, I would like error handling to be invoked, if possible from biopieces.rb, in the case some exception is raised (either by raise or ctrl-c, etc), but I am not defining any methods and thus the suggested meta-programming approaches seem to fall short. Cheers, Martin -- Posted via http://www.ruby-forum.com/.