✳️ 例外クラスの継承
code:.rb
class SomeError < StandardError; end
class SomeOtherError < SomeError; end
def meth1
raise SomeOtherError.new("error")
end
begin
meth1
rescue SomeError # SomeOtherErrorはSomeErrorのサブクラスなので、SomeErrorに該当して実行される
print "SomeError"
rescue SomeOtherError
print "SomeOtherError"
end
# 実行結果
SomeError