Hello World

Be Happy!

ruby raise rescue example


def test_a
  puts "start test_a"
  test_b
  puts "end test_a"
rescue => e
  puts "called rescue in test_a"
  puts e.message
end

def test_b
  puts "start test_b"
  test_c
  puts "end test_b"
end

def test_c
  puts "start test_c"
  raise "called raise in test_c"
  puts "end test_c"
end

irb
irb(main):247:0> test_a
start test_a
start test_b               
start test_c               
called rescue in test_a    
called raise in test_c     
=> nil     
#ruby (12) #exception (1) #raise (1)
List