-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fixed SystemStackError #18
base: master
Are you sure you want to change the base?
Conversation
Thanks, @olhor for working on the solution. @rmustafin It would be really helpful if you can review this PR as soon as possible. We are about to deploy this on production and don't want to run into this error. ( We are using latest Thanks in advance. |
Fix: calling "indirect_rate" method when rates are not defined throws SystemStackError: stack level too deep.
fc5b8d6
to
66e74bb
Compare
@olhor Tried to use the solution provided here and there is a possible issue with the implementation. Using the gem with Ruby Money gem like this.
When the rate is not available then it should throw |
I will try to check what we can do to fix it. Thanks. |
This is what I get:
Are there any prerequisites? Should the rates be present? |
@olhor Oh 🤔
Doing it like this -
|
divider = original_get_rate('RUB', from) | ||
return nil if dividend.nil? || divider.nil? | ||
|
||
dividend.to_f / divider.to_f |
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.
@olhor Can we trim it down to this ?
def indirect_rate(from, to)
get_rate('RUB', to) / get_rate('RUB', from)
dividend = original_get_rate('RUB', to)
divider = original_get_rate('RUB', from)
dividend && divider && dividend.to_f / divider.to_f
end
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.
Line get_rate('RUB', to) / get_rate('RUB', from)
will throw an exception if get_rate
returns nil.
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.
@olhor I am sorry. I missed to remove that line -
def indirect_rate(from, to)
dividend = original_get_rate('RUB', to)
divider = original_get_rate('RUB', from)
dividend && divider && dividend.to_f / divider.to_f
end
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.
No problem for me.
@olhor Really appreciate your work and communication to resolve the issue. Thank you. |
@rmustafin Please check. |
@olhor any chance we can merge this ? |
@arpit1094 Don't ask me. I am not a maintainer, I do not have write access. |
Fix: calling "indirect_rate" method when rates are not defined throws SystemStackError: stack level too deep.