这只打印rescue 1
,有没有办法打印rescue 1
和rescue 2
?
def mimiti
raise 'hi there!'
rescue
puts 'rescue 1'
end
begin
mimiti
rescue
puts 'rescue 2'
end
答案 0 :(得分:2)
是的,您可以在捕获并处理它之后重新引发异常:
def mimiti
raise 'hi there!'
rescue StandardError => e
puts 'rescue 1'
raise e
end