From: "danilo.s.coelho (Danilo Coelho)" Date: 2012-11-25T21:00:09+09:00 Subject: [ruby-core:50074] [ruby-trunk - Bug #7430] 'unexpected return' occurs when call a Proc that returning value in rescue Issue #7430 has been updated by danilo.s.coelho (Danilo Coelho). In fact, there is no problem with 'return' in 'rescue'. My intention is to return after the Proc not continue execution. Like this: def test puts "start: test" p = Proc.new do |date_str| begin require "time" Time.parse(date_str) puts "date #{date_str} is valid" rescue Exception => e return "error handled by proc: #{e}" end end p.call("01/01/2012") p.call("80/01/2012") puts "finish: test" end test But just does not work: def validator Proc.new do |date_str| require "time" begin Time.parse(date_str) puts "date #{date_str} is valid" rescue Exception => e return "error handled by proc: #{e}" end end end def test puts "start: test" v = validator v.call("01/01/2012") v.call("81/01/2012") puts "finish: test" end test ---------------------------------------- Bug #7430: 'unexpected return' occurs when call a Proc that returning value in rescue https://bugs.ruby-lang.org/issues/7430#change-33853 Author: danilo.s.coelho (Danilo Coelho) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p286 (2012-10-12) [i386-mingw32] p = Proc.new do begin 1 / 0 rescue return "error handled by proc" end end p.call -- http://bugs.ruby-lang.org/