the-alchemists-of-arland / gray-matter-rs

A tool for easily extracting front matter out of a string. It is a fast Rust implementation of gray-matter. Parses YAML, JSON, TOML and support for custom parsers. Use it and let me know by giving it a star!
https://docs.rs/gray_matter
MIT License
37 stars 4 forks source link

Allow engine parser errors to be handled #22

Open ViciousBadger opened 5 days ago

ViciousBadger commented 5 days ago

In engines/toml.rs (and similar in the other engines)

impl Engine for TOML {
    fn parse(content: &str) -> Pod {
        match toml::from_str::<Value>(content) {
            Ok(value) => value.into(),
            Err(_) => Pod::Null,
        }
    }
}

This makes it more difficult to troubleshoot issues with front matter parsing, since any internal error thrown by the parser is completely hidden. It would be nice if the Pod enum instead contained an error state containing whatever error type the internal parser uses. (Or something like that, I'm no expert)

yuchanns commented 5 days ago

SGTM.