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

feat(endo): Improve JSON file parse error messages #430

Merged
merged 1 commit into from
Aug 26, 2020

Conversation

kriskowal
Copy link
Member

This change annotates JSON syntax errors with the location of the originating file throughout Endo.

@kriskowal kriskowal requested a review from warner August 25, 2020 00:40
@kriskowal kriskowal mentioned this pull request Aug 25, 2020
36 tasks
try {
return JSON.parse(source);
} catch (error) {
throw new SyntaxError(`Cannot parse JSON from ${location}, ${error}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new SyntaxError(`Cannot parse JSON from ${location}, ${error}`);
if (error instanceof SyntaxError) {
throw new SyntaxError(`Cannot parse JSON from ${location}, ${error}`);
} else {
throw error;
}

See also my comments in #431 about whether the following approach might be better:

Suggested change
throw new SyntaxError(`Cannot parse JSON from ${location}, ${error}`);
if (someAppropriateOption) {
console.log(`Cannot parse JSON from ${location},`, error);
}
throw error;

Copy link
Contributor

@warner warner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

Base automatically changed from kris/endo-cycles to kris/endo-mitm August 26, 2020 19:02
@kriskowal kriskowal merged commit 8b0c01b into kris/endo-mitm Aug 26, 2020
@kriskowal kriskowal deleted the kris/endo-json-errors branch August 26, 2020 19:02
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.

3 participants