TypeError (class or module required for rescue proposal)

I've been using Stripe for over a year now, based on the Ryan Bates RailsCast episode I found here . However, my error handling recently stopped working and I have never seen this error before. I recently started running my application on Ruby 2.1 and as far as I can tell this is a problem.

This is the instance method in my model Subscription

:

    begin
      save_with_stripe_payment
    rescue Stripe::InvalidRequestError => e
      logger.error "Stripe error while creating customer: #{e.message}"
      logger.error e.backtrace.join("\n")
      errors.add :base, "There was a problem with your card."
      false
    rescue e
      logger.error e.message
      logger.error e.backtrace.join("\n")
      errors.add :base, e.message
      false
    end

      

Line:

    rescue Stripe::InvalidRequestError => e

      

is a bug. The structure from there goes to the "start" line, and that's it. What am I missing here?

+4


source to share


2 answers


The line number in the error is a little misleading, the error actually comes from this:

rescue e

      



I think you meant

rescue => e

      

+9


source


I got this error because I was trying to save an array of exceptions like

rescue *exceptions => e

      



for exceptions

being an exceptions

instance of an exception (my mistake).

0


source







All Articles