spree/spree — pull request #3269 by huoxito (2013-06-27 06:00:31+00:00)
Title: Edge raises when rates arent created

Hi there, started looking into #2958 and ended up changing more than I expected.

I believe there are too many rescues spread on the code base for the same `order.process_payments!` code, when that method itself already rescues the exception. So I removed duplicated code from `Order::Checkout` regarding this. I also removed the `rescue_from GatewayError` in `CheckoutController` because that method was never being called anyway afaik. The same error was being rescued two times already on the stack.

The third commit adds a new attribute to Order so that we can better keep track of errors during checkout transitions and display a generic message when no error is specified. Currently spree assumes every transition fails because of a payment error.

The last commit resolves #2958 by raising an error when spree can't generate any shipping rate for a package. This one breaks the build, just realized after running backend and frontend. I believe it's probably because I need to treat the exception somewhere else. I'd make another PR for it but it kind of depends on the previous commits to display the message during checkout. As far as I can see it might be better to raise a custom exception than having `undefined method for nilClass` later on.

Please let me know what you think about it. I've seen the error described in #2958 many times while working on other issues and it would be great to have a solution for that. Maybe we can come up with another one for that here if this PR doesn't look right.