Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CLI parsing error #455

Merged
merged 1 commit into from
May 21, 2015
Merged

Improve CLI parsing error #455

merged 1 commit into from
May 21, 2015

Conversation

phillipj
Copy link
Collaborator

I've become fund of human readable and informative error messages with tips lately ;) Would you agree this has some benefits compared to the raw exception stack from JSON.parse()?

Somewhat inspired by issue #429 expecting functions to be valid JSON.

echo {name:'lebron'} | ./bin/mustache - test/_files/cli.mustache 
undefined:1
{name:lebron}
 ^
SyntaxError: Unexpected token n
    at Object.parse (native)
    at /mustache.js/bin/mustache:49:13

vs

echo {name:'lebron'} | ./bin/mustache - test/_files/cli.mustache 
Shooot, could not parse view as JSON.
Tips: functions are not valid JSON and keys / values must be surround with double quotes.

SyntaxError: Unexpected token n
    at Object.parse (native)
    at parseView (/mustache.js/bin/mustache:55:17)
    at /mustache.js/bin/mustache:49:8

@dasilvacontin
Copy link
Collaborator

This is awesome. Thanks @phillipj, love it! 😄

dasilvacontin added a commit that referenced this pull request May 21, 2015
@dasilvacontin dasilvacontin merged commit 519669d into master May 21, 2015
@dasilvacontin dasilvacontin deleted the improve/cli-parse-error branch May 21, 2015 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants