Showing posts with label exceptions. Show all posts
Showing posts with label exceptions. Show all posts

Wednesday, November 6, 2013

Ruby: exceptions

raise "Exception message" // this will throw RuntimeError exception with message "Exception message"

begin
  10/0 // This will raise an DivisionByZero exception
rescue DivisionByZero
  puts "Devision by zero exception"
end
Creating custom exception:
class CustomException > StandardError
end