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

Error throwing #4

Closed
peterbe opened this issue May 30, 2019 · 1 comment
Closed

Error throwing #4

peterbe opened this issue May 30, 2019 · 1 comment

Comments

@peterbe
Copy link
Contributor

peterbe commented May 30, 2019

One thing I've noticed when running the cli is that the errors thrown are hard to map to which document (aka. which stumptown .json) was the cause.
Perhaps I don't know how to use sourcemaps in Node. (remember the cli is babel'ified into dist/cli.js) or perhaps it's just the nature of Node tracebacks being not great.

A quick fix would be to change, for example:

throw new Error(
   `prose section '${name}' is not optional and not present in document.prose`
);

to something like:

throw new Error(
   `prose section '${name}' is not optional and not present in document.prose (on ${document.title)`
);

...or something similar. That would make sense when using the cli and it might come in hand when we connect the cli with Travis. But it doesn't make sense to repeat the obvious when you're doing dev in the browser because which document it is is clear from the URL bar.

Another thing to ponder is that going into production; it might be nice to NOT throw errors and just use console.error() instead. So whatever we do we could leverage process.env.NODE_ENV.

@peterbe
Copy link
Contributor Author

peterbe commented Jun 20, 2019

Instead, solved by this: https://github.com/peterbe/mdn2/blob/0e8b0fe85a9ffa46f8590b2fd7ef29786e04f639/cli/index.js#L85-L87

When you're editing a single page by visiting localhost:3000/docs/Foo/Bar/thing you already know that the original problem comes from "thing.json".

@peterbe peterbe closed this as completed Jun 20, 2019
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

No branches or pull requests

1 participant