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

#parse does not rescue all errors #166

Closed
shamas- opened this issue Jul 20, 2023 · 1 comment
Closed

#parse does not rescue all errors #166

shamas- opened this issue Jul 20, 2023 · 1 comment

Comments

@shamas-
Copy link

shamas- commented Jul 20, 2023

Repro steps:

Monetize.parse(1+3i)

Expected:

=> nil

Actual:

ArgumentError: Unable to make a BigDecimal from non-zero imaginary number

Using Ruby 3.0.6.

It might be because Error inherits from StandardError

class Error < StandardError; end

and is used here

monetize/lib/monetize.rb

Lines 29 to 33 in e2e2f1f

def parse(input, currency = Money.default_currency, options = {})
parse! input, currency, options
rescue Error
nil
end

If I do

begin
  Monetize.parse(1+3i)
rescue StandardError
  pp 'hi there'
end

the error is rescued.

@semmons99
Copy link
Member

please submit a PR for consideration

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

No branches or pull requests

2 participants