S
Srijayanth Sridhar
[Note: parts of this message were removed to make it a legal post.]
Hello,
The following code:
require 'optparse'
optparser = OptionParser.new do |args|
list=[:foo,:bar,:baz]
begin
args.on("--l [OPTION]",list,"Blah") { |o| }
rescue
puts "Rescuing in the block"
end
end
begin
optparser.parse!(ARGV)
rescue
puts "Rescuing in main"
end
/foo.rb -l FOO ends up being rescued in main.
Why is this? the parse! method just calls the block defined in new doesn't
it? In which case, a begin and rescue block should work there right? Even if
I remove the begin and rescue block in main, it doesn't get rescued at all,
it just ends up spitting the usual ugly error etc.
I am currently on Ruby 1.8.6.
Thanks,
Jayanth
Hello,
The following code:
require 'optparse'
optparser = OptionParser.new do |args|
list=[:foo,:bar,:baz]
begin
args.on("--l [OPTION]",list,"Blah") { |o| }
rescue
puts "Rescuing in the block"
end
end
begin
optparser.parse!(ARGV)
rescue
puts "Rescuing in main"
end
/foo.rb -l FOO ends up being rescued in main.
Why is this? the parse! method just calls the block defined in new doesn't
it? In which case, a begin and rescue block should work there right? Even if
I remove the begin and rescue block in main, it doesn't get rescued at all,
it just ends up spitting the usual ugly error etc.
I am currently on Ruby 1.8.6.
Thanks,
Jayanth