Proposal: Improved error messages and handling
See original GitHub issuetldr; put some effort into improving our error messaging across the board in DoneJS, but especially in StealJS and done-ssr.
This was discussed on a recent live stream (30:19).
The Problem
live-reload is a fantastic tool for helping with rapid development of application. But if your app gets into an awkward state, like when you have a syntax error, it can be difficult to understand what the problem is and figure out how to fix it.
The Solution
We would like to put some effort into improving our error messaging. Some inspiration comes from other frameworks, such as create-react-app which gives errors like:
When there is a syntax error.
Elm gives good error messages when there is a compilation error:
What if we could produce error messages that specifically showed bad code. Imagine code like:
let map = new DefineMap();
map.set('bar');
What if we could display an error message (in the console? Maybe in the browser some how too?) that was:
Missing required argument.
2|> let map = new DefineMap();
3|>
4|> map.set('bar');
`set` expects to be passed 2 arguments.
This would be quite useful as it would give a dynamic language like JavaScript some of (but not all of course) the benefits of static languages by pointing out mistakes.
Tasks
We can’t just jump to implementation as we really need to get a good handle on what users are actually facing. I think the steps would be:
- Spend a few days just trying to break DoneJS in as many ways as possible, documenting what was done and what the result is (a screenshot if possible).
- Spend a few more days doing some analysis of other tools and how they handle these types of mistakes.
- Build a system so that we can gather more detailed information on errors.
- Design how we will display these errors. Should it be done in the console? Or specially handled in each environment (maybe an overlay in the browser and special formatting in the terminal?). Research in (2) will inform our choices here.
- Implement and show off!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (7 by maintainers)
Top GitHub Comments
Another stealjs one that I’m not sure is already reported, what happens if package.json isn’t valid, is missing a main, etc.