Skip to content

feat(json): log the filename when JSON.parse fails#417

Merged
shellscape merged 1 commit intorollup:masterfrom
bennypowers:patch-1
Jun 3, 2020
Merged

feat(json): log the filename when JSON.parse fails#417
shellscape merged 1 commit intorollup:masterfrom
bennypowers:patch-1

Conversation

@bennypowers
Copy link
Copy Markdown
Contributor

@bennypowers bennypowers commented May 26, 2020

Rollup Plugin Name: json

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

Helpful when debugging
Sometimes in a large codebase, a single comma buried in a gigantic json file can halt the entire build. This change ensures that users will more easily be able to find and fix those errors.

@bennypowers bennypowers force-pushed the patch-1 branch 2 times, most recently from 78db740 to 0d3c00e Compare May 26, 2020 18:45
@bennypowers bennypowers force-pushed the patch-1 branch 2 times, most recently from 795fbcb to 0efe962 Compare May 26, 2020 19:59
@bennypowers
Copy link
Copy Markdown
Contributor Author

This should be ready to go now

Copy link
Copy Markdown
Collaborator

@shellscape shellscape left a comment

Choose a reason for hiding this comment

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

This is good for this PR, but before we publish this change I want to utilize a custom error class and do some more maintenance on this plugin. Changing Error expectations means a major version, so it's a good time to tackle that.

} catch (err) {
const error = new Error(`Could not parse ${id}`);
error.originalError = err;
throw error;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I sat on this for a while and I'm glad that I did. I'd like to see this use this.warn rather than throwing the error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated

Copy link
Copy Markdown
Collaborator

@shellscape shellscape left a comment

Choose a reason for hiding this comment

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

Helpful when debugging
Sometimes in a large codebase, a single comma buried in a gigantic json file can halt the entire build. This change ensures that users will more easily be able to find and fix those errors.
@shellscape
Copy link
Copy Markdown
Collaborator

thanks!

@shellscape shellscape merged commit 28f9869 into rollup:master Jun 3, 2020
@bennypowers bennypowers deleted the patch-1 branch June 4, 2020 07:07
LarsDenBakker pushed a commit to LarsDenBakker/plugins that referenced this pull request Sep 12, 2020
Helpful when debugging
Sometimes in a large codebase, a single comma buried in a gigantic json file can halt the entire build. This change ensures that users will more easily be able to find and fix those errors.
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