LoginSignup
0
0

More than 1 year has passed since last update.

Ruby の例外の伝播

Posted at

いつも忘れるので。

def method1
  method2
rescue => e
  p "rescued in method1 #{e.message}"
end

def method2
  if false
    p 'success'
  else
    raise "raised in method2"
  end
end

method1
# => "rescued in method1 raised in method2"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0