From 3a1edc25afcab9bbc4025f7355d730ab698dd1c8 Mon Sep 17 00:00:00 2001 From: Brian Quinn Date: Tue, 28 Sep 2010 19:42:12 +0100 Subject: [PATCH] Handle shipping errors raises by calculator gracefully during admin orders --- active_shipping_extension.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/active_shipping_extension.rb b/active_shipping_extension.rb index aa45454d10..36c9fe72f4 100644 --- a/active_shipping_extension.rb +++ b/active_shipping_extension.rb @@ -51,6 +51,18 @@ def activate Calculator::Usps::PriorityMailLargeFlatRateBox ].each(&:register) + # handle shipping errors gracefully on admin ui + Admin::ShipmentsController.class_eval do + rescue_from Spree::ShippingError, :with => :handle_shipping_error + + private + def handle_shipping_error(e) + load_object + flash.now[:error] = e.message + render :action => "edit" + end + end + #Only required until following active_shipping commit is merged (add negotiated rates). #http://github.com/BDQ/active_shipping/commit/2f2560d53aa7264383e5a35deb7264db60eb405a ActiveMerchant::Shipping::UPS.send(:include, Spree::ActiveShipping::UpsOverride)