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

ArgumentError message is not meaningful #2

Closed
andreapavoni opened this issue Jan 13, 2017 · 0 comments
Closed

ArgumentError message is not meaningful #2

andreapavoni opened this issue Jan 13, 2017 · 0 comments

Comments

@andreapavoni
Copy link

Hi there,

while using your gem, I've noticed that in case of ArgumentError (raised here) does not give any clues about what generated the error:

#<ArgumentError: #<ActiveModel::Errors:0x007fd7680184b0>>

you should change the line with something like this:

raise ArgumentError.new("#{citizen.errors.inspect}") unless citizen.valid?

and now you'll get the entire ActiveModel::Errors object:

#<ActiveModel::Errors:0x007f9d741933e0 @base=#<CodiceFiscale::ItalianCitizen:0x007f9d74193688 @attributes={:country_name=>"Italia", :name=>"Mario", :surname=>"Rossi", :gender=>:male, :birthdate=>Thu, 01 Jan 1987, :city_name=>654270}, @country_name="Italia", @name="Mario", @surname="Rossi", @gender=:male, @birthdate=Thu, 01 Jan 1987, @city_name=654270, @validation_context=nil, @errors=#<ActiveModel::Errors:0x007f9d741933e0 ...>>, @messages={:province_code=>["non può essere lasciato in bianco"]}>
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

1 participant