jm / toml

Parse TOML. Like a bawss.
MIT License
151 stars 38 forks source link

raise error when parser fails #47

Closed logicminds closed 3 years ago

logicminds commented 7 years ago

https://github.com/jm/toml/blob/master/lib/toml/parser.rb#L11

I want to be able to catch this error and do something more intelligent when I am using this library in my project.

Can you just remove the code?

aycyang commented 5 years ago

Another reason to remove this code is to avoid relying on the interface of Parslet::ParseFailed, in this case the attribute .cause. This became a problem in the 0.2.0 release of this gem, when the parslet dependency version was bumped from 1.6.2 to 1.8.0.

Starting from parslet 1.8.0, .cause was renamed to .parse_failure_cause (commit).

So when you try to parse some invalid TOML, instead of ParseFailed you get NoMethodError as ruby tries to call ascii_tree on nil.