i am creating some custom exceptions as follows
lib/exceptions.rb
module Exceptions
class MemberOverFlow < StandardError
end
rescue_from MemberOverFlow do |exception|
redirect_to root_url, :alert => exception.message
end
end
I use to raise the exception like this.
raise Exception::MemberOverFlow"member count overflow"
It giving the following error
NoMethodError in MembersController#create
undefined method `MemberOverFlow' for Exception:Class
can anyone tell me what is problem
thanks
Did you require the module in the controller where you are trying to raise the exception?
require "exception" #or wherever you have placed the module fileUse:
raise Exception::MemberOverFlow.new("member count overflow")and if it still does not work, try changing the name of the module “Exception” because Exception is an existing exception class defined in Ruby.