Last active
March 16, 2018 10:10
-
-
Save dlamichhane/4a0ae9fe91cf4cbb697bfb47c0ea2824 to your computer and use it in GitHub Desktop.
Ruby Exception
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 Me | |
LimitException = Class.new(StandardError) | |
LimitException2 = Class.new(StandardError) | |
class Sync | |
def self.find_me(digit) | |
raise LimitException if digit == 1 | |
raise LimitException2 if digit == 2 | |
puts digit | |
end | |
end | |
end | |
[1,2,3,4,5].each do |digit| | |
begin | |
Me::Sync.find_me(digit) | |
rescue Exception => e | |
puts e.message | |
next | |
rescue Me::LimitException => e | |
puts e.message | |
break | |
rescue Me::LimitException2 => e | |
puts e.message | |
next | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment