salesking / sepa_king

Ruby gem for creating SEPA XML files
MIT License
149 stars 118 forks source link

undefined method `match' for nil:NilClass #22

Closed noozo closed 10 years ago

noozo commented 10 years ago

Happens when generating the xml, i.e.: sdd.to_xml

Any idea what might be causing it?

ledermann commented 10 years ago

Do you have a stack trace?

noozo commented 10 years ago

Was just about to reply to myself. It happens when the creditor_identifier is invalid. Can you handle it more gracefully? :)

ledermann commented 10 years ago

It would be very helpful to get the stack trace or at least the line number of the failing code. Additionally, please tell me an example creditor_identifier which raises this exception. Better would be a failing test, best is creating a pull request ;-)

noozo commented 10 years ago

You're right :)

If you use nil it believe it will throw this. Didn't try with empty string or a non-valid string.

Here's the stack:

sepa_king (0.1.0) lib/sepa_king/validator.rb:31:in valid?' sepa_king (0.1.0) lib/sepa_king/validator.rb:23:invalidate' activesupport (3.2.14) lib/active_support/callbacks.rb:310:in _callback_before_7' activesupport (3.2.14) lib/active_support/callbacks.rb:440:in_run313393702109351557validate4199759393947241247callbacks' activesupport (3.2.14) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.14) lib/active_support/callbacks.rb:385:in_run_validate_callbacks' activesupport (3.2.14) lib/active_support/callbacks.rb:81:in run_callbacks' activemodel (3.2.14) lib/active_model/validations.rb:228:inrun_validations!' activemodel (3.2.14) lib/active_model/validations.rb:195:in valid?' sepa_king (0.1.0) lib/sepa_king/message.rb:16:inblock in class:Message' activesupport (3.2.14) lib/active_support/callbacks.rb:418:in _run__682144103491543913__validate__4199759393947241247__callbacks' activesupport (3.2.14) lib/active_support/callbacks.rb:405:in__run_callback' activesupport (3.2.14) lib/active_support/callbacks.rb:385:in _run_validate_callbacks' activesupport (3.2.14) lib/active_support/callbacks.rb:81:inrun_callbacks' activemodel (3.2.14) lib/active_model/validations.rb:228:in run_validations!' activemodel (3.2.14) lib/active_model/validations.rb:195:invalid?' sepa_king (0.1.0) lib/sepa_king/message.rb:34:in to_xml' app/models/cobranca.rb:129:ingerar_ficheiro_sepa'

ledermann commented 10 years ago

I see you are using v0.1.0. Please try the lastet code from the repo, which contains some unreleased features regarding validations.

noozo commented 10 years ago

Cool. Though keep in mind that most people will probably use the gem, so you might want to release another one ;)

ledermann commented 10 years ago

Sure, next release will be published in the very near future. Is your issue fixed with the latest code?

noozo commented 10 years ago

Can't try it right now, as i'm working in another project. But as soon as i can i'll update you. Thanks.