[Dancer-users] User-friendly errors on YAML parsing failures (was: Re: dancer croaking with a strange error in config.yml)
David Precious
davidp at preshweb.co.uk
Mon Nov 14 17:27:39 CET 2011
On Monday 14 November 2011 16:16:29 Brian E. Lozier wrote:
> On Mon, Nov 14, 2011 at 8:11 AM, David Precious <davidp at preshweb.co.uk>
> > Also, if the parsing failed, open config.yml and skim over it, and report
> > any lines which included tabs, with the line number.
> >
> > This would be a fairly small amount of code, and would only come into
> > play if the parsing of config.yml failed (in which case, the app is
> > unlikely to start anyway, so it's not like it's extra complexity /
> > expense in the majority of cases).
>
> It seems like it would be better to contribute to the YAML module
> itself so it could report errors like this, as opposed to doing
> post-processing on an already-failed file.
Hmm, yeah, that could make sense - although I think YAML.pm is to be replaced
with essentially YAML::Any at some point. Getting all the parsers to output a
friendly message is likely harder than just outputting a fairly generic
message ourselves.
We could have the message refer to an FAQ entry which lists various common
mistakes in YAML for more details, perhaps.
> Also, aren't tabs allowed
> inside quoted values? By the time you take into account all the valid
> possibilities, you will have rewritten a YAML parser.
Yeah, that's why I mentioned earlier in the message "look for any tabs in the
file (before any non-whitespace chars)" - yes, tabs within quoted values
should be valid, so I'd look only for e.g. /^\s*\t/ or similar.
Cheers
Dave P
More information about the Dancer-users
mailing list