Equivalent scrapbook

…scrap on Rescue begin rails

exceptions, begin rescue

http://www.skorks.com/2009/09/ruby-exceptions-and-exception-handling/

    begin
    # Your normal code block
    rescue SomeException
    # ... handling exception
    else
    # This part only run if the main code did not throw
    # an exception.
    ensure
    # The very last thing to be run before the clause exit.
    # Code in the ensure clause will always get execute.
    end
raise ZeroDivisionError


begin
  raise ZeroDivisionError, "Hello I am a random zero division error"
rescue ZeroDivisionError => e
  p e.message
  p e.backtrace
end
notification_message = Notification.last #(with column exeption_message)

begin
  #...
recue Api::Exception::FacebookOpenGraph => e
  notification_message.exception_message = "#{e.class} => #{e.message}"
  notification_message.save
  return false
 end

Custom Exceptions

class MyCrazyException < Exception
end

raise MyCrazyException, "I am a crazy new exception"