Created
June 20, 2019 15:15
-
-
Save webuilder240/2824ee1d0135678a84d0297ec3e9f36a to your computer and use it in GitHub Desktop.
例外の階層構造
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Nick | |
class NickError < StandardError; end | |
class NoCustomerError < NickError; end | |
class NoCardError < NickError; end | |
class NoMoneyError < NickError; end | |
end | |
begin | |
raise Nick::NoMoneyError.new() | |
rescue Nick::NickError => e | |
puts "#{e.class}はここにやってくる" | |
rescue => e | |
puts "ここにはこない" | |
end | |
begin | |
raise Nick::NickError.new() | |
rescue Nick::NoCardError, | |
Nick::NoCustomerError => e | |
puts "ここにはこない" | |
rescue => e | |
puts "#{e.class}はここにやってくる" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment