Created
October 20, 2023 19:48
-
-
Save aks/4a8809d45d5e5ad022ac55aa262cc12d to your computer and use it in GitHub Desktop.
Ruby script to show sub-class exceptions rescued before parent class exceptions
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
#!/usr/bin/env ruby | |
require 'awesome_print' | |
class Error < StandardError; end | |
class SpecificError < Error ; end | |
class Tester | |
def self.run | |
raise SpecificError | |
rescue Error, SpecificError => e | |
puts "caught: #{e.class}, #{e}" | |
end | |
end | |
Tester.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment