Posts Tagged ‘exception’

How to raise and rescue Exceptions in Ruby on Rails

Creating the Exception class
To create our “PersonalException” we just need to extend “Exception” class.

class PersonalException < Exception
end

Raise our Exception

raise PersonalException.new, “message”

Rescue our exception
We can do this by overwriting rescue_action_in_public and local_request? functions to our application.rb file: