Skip to content

Instantly share code, notes, and snippets.

@dlamichhane
Last active March 16, 2018 10:10
Show Gist options
  • Save dlamichhane/4a0ae9fe91cf4cbb697bfb47c0ea2824 to your computer and use it in GitHub Desktop.
Save dlamichhane/4a0ae9fe91cf4cbb697bfb47c0ea2824 to your computer and use it in GitHub Desktop.
Ruby Exception
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