-
-
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
Raise exception if dividing by 0 #3305
Conversation
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.
👍 Probably not a bad idea. Thanks!
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'm fine with this change but I'd move the raise in the caller method. Let me know your thoughts and thanks!
d8c10ac
to
104897d
Compare
@ericsaupe just thinking: wouldn't this lead to another exception ZeroDivisionError without the need to explicitly raise it? |
@kennyadsl because |
It probably makes more sense to really return that error. I'll change that. |
While this should never happen it is possible to call this method and subsequently try to save a NaN value if the line_item has already been fully cancelled.
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.
Thanks @ericsaupe!
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.
Looks fine
While this should never happen it is possible to call this method
and subsequently try to save a NaN value if the line_item has
already been fully cancelled.
Description
This came up in our store today. I was unable to recreate it but somehow one of our customer service representatives short shipped an item and the adjustment, and subsequent adjustment total on the order, went to
NaN
. Looking into the calculation it looks like it may be possible for the short ship compute amount to return that result. This PR raises an exception if, somehow, that method is called and tries to divide by 0.Checklist: