exceptions in ruby

I inherited some interesting code last week. A user has the ability to sign into the website with omniauth.

{% codeblock lang:ruby %} def num puts “Enter a number” num = gets.chomp.to_i

if num == 3
    puts "It's a 3!"
    else
        raise "Wrong number, you entered a #{num}"
end

end

def num2 num end

begin num2 rescue Exception => ex puts ex end {% endcodeblock %}

Reference

Ruby Exception Class

comments powered by Disqus