I've got a custom Exception class declared like so:
class CustomError < StandardError
def initialize(message = nil)
@message = message
@type = "custom_error"
end
end
That is being handled in my Application controller like so:
rescue_from CustomError do |e|
render json: e.type
end
Now, when I raise the Exception using raise CustomError.new("Oops I did it again")
I get a NoMethodError
with undefined method `type'
What's going on? Why can't I just access type
using e.type
?