Skip to content
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

improve the wording of the to_money deprecations warning #283

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

elfassy
Copy link
Contributor

@elfassy elfassy commented Mar 22, 2024

Why

We want to track deprecations happening with the .to_money method seperatly from those from arithmetic computations. This will allow us to safely raise knowing these issues no longer happen in production

What

Introduce a new deprecation warning message for to_money with inconsistent currencies

Before:

Money.new(1, "USD").to_money("CAD") 
# "mathematical operation not permitted for Money objects with different currencies CAD and USD. A Money::IncompatibleCurrencyError will raise in the next major release"

After:

Money.new(1, "USD").to_money("CAD") 
# "to_money is attempting to change currency of an existing money object from USD to CAD. A Money::IncompatibleCurrencyError will raise in the next major release"

Note

This only affects those using the legacy_deprecations option. Others will continue to get an Money::IncompatibleCurrencyError exception

@Shopify/shopify-money

@elfassy elfassy force-pushed the split_to_money_deprecation_warnings branch from ff9a9c4 to 1c0b0c7 Compare March 22, 2024 14:27
@lavoiesl lavoiesl requested a review from chitty March 22, 2024 18:41
@lavoiesl
Copy link
Contributor

Tagging in @chitty, who recently bumped Russbot to Money 2.0 and saw a lot of those warnings

Copy link

@chitty chitty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, I also find the resulting code more readable 🙌

@elfassy elfassy merged commit 82c84d0 into main Mar 25, 2024
9 checks passed
@elfassy elfassy deleted the split_to_money_deprecation_warnings branch March 25, 2024 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants