chronic icon indicating copy to clipboard operation
chronic copied to clipboard

Crash: Undefined method '+' for nil:Nilclass

Open bramski opened this issue 7 years ago • 3 comments

NoMethodError (undefined method `+' for nil:NilClass):
/Users/bram/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/chronic-0.10.2/lib/chronic/repeaters/repeater_minute.rb:48:in `offset'
/Users/bram/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/chronic-0.10.2/lib/chronic/handlers.rb:431:in `handle_srp'
/Users/bram/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/chronic-0.10.2/lib/chronic/handlers.rb:457:in `handle_s_r_a_s_r_p_a'
/Users/bram/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/chronic-0.10.2/lib/chronic/handler.rb:76:in `invoke'
/Users/bram/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/chronic-0.10.2/lib/chronic/parser.rb:254:in `block in tokens_to_span'
/Users/bram/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/chronic-0.10.2/lib/chronic/parser.rb:251:in `each'
/Users/bram/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/chronic-0.10.2/lib/chronic/parser.rb:251:in `tokens_to_span'
/Users/bram/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/chronic-0.10.2/lib/chronic/parser.rb:61:in `parse'
/Users/bram/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/chronic-0.10.2/lib/chronic.rb:90:in `parse'

Failing on the string "26 of November 3 to 5"

bramski avatar Nov 23 '17 20:11 bramski

Such format isn't supported.

davispuh avatar Nov 24 '17 00:11 davispuh

This much I know. But Chronic shouldn't crash my app. It's supposed to return nil if it can't parse it.

bramski avatar Nov 24 '17 00:11 bramski

Yeah, that's why it's also a bug but there are a lot of inputs which could crash it, you should catch those exceptions even if Chronic would be 100% safe.

davispuh avatar Nov 24 '17 00:11 davispuh