Hacker News new | past | comments | ask | show | jobs | submit login

Browser JSON parsers probably shouldn't be optimized for user friendliness, since to the users running the program any error message is going to be unfriendly. They are optimized for speed, and if nice error messages slow thing down at all, then bare messages it is.

Maybe there's a way to re-parse with a friendly parser with there's an error and dev tools is open.




In a language I worked on ( github.com/skiplang/skip ), at the moment where we throw a syntax error, we can look at the previous few tokens and generate much better error message.

In the case of the above, if last is ], previous is number and before is 0, then put a nice error message where octal notation is not allowed.

This is not “pure” from a language theory sense but in practice if you add a handful of common ones, it makes for a much better experience.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: