-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always pass the new order number on unreturned exchange failures #388
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,13 @@ namespace :exchanges do | |
begin | ||
item_charger.charge_for_items | ||
rescue Spree::UnreturnedItemCharger::ChargeFailure => e | ||
failure = {message: e.message, new_order: e.new_order.try(:number)} | ||
rescue Exception => e | ||
failure = {message: "#{e.class}: #{e.message}"} | ||
failure = { message: e.message } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can now just collapse this into the |
||
rescue => e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @magnusvk @gmacdougall changing this to But with this update we now have the problem that our We could add: rescue Exception
Spree::UnreturnedItemCharger.failure_handler.call(failures) if Spree::UnreturnedItemCharger.failure_handler
raise
end but that might not be good, depending on what the non-StandardError is. Or we could add more rescues like Or we could change our failure handler so that it was called right away for each error as it occurred. That seems like the most sane option to me. Or we could just keep this as it is now and not worry about any of this. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with rescuing Exception as long as we re-raise it. It's just not one of those things that should be swallowed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gmacdougall yeah but if it's a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'd just collapse these and not think about rescuing non- |
||
failure = { message: "#{e.class}: #{e.message}" } | ||
end | ||
|
||
if failure | ||
failure[:new_order] = item_charger.new_order.number if item_charger.new_order | ||
failures << failure.merge({ | ||
order: item_charger.original_order.number, | ||
shipment: shipment.number, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just do
@new_order = ...
, but this is a cool style!