Skip to content

Commit

Permalink
Merge pull request #4676 from jzhang026/chore/error-packageJSON-filename
Browse files Browse the repository at this point in the history
Given out the filename of the local projects package.json file where the error occured during rush command
  • Loading branch information
iclanton authored May 6, 2024
2 parents 21afaae + 5eb1a2b commit 49d93a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Provide the file path if there is an error parsing a `package.json` file.",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
5 changes: 5 additions & 0 deletions libraries/rush-lib/src/api/RushConfigurationProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ export class RushConfigurationProject {
if (FileSystem.isNotExistError(error as Error)) {
throw new Error(`Could not find package.json for ${packageName} at ${packageJsonFilename}`);
}

// Encountered an error while loading the package.json file. Please append the error message with the corresponding file location.
if (error instanceof SyntaxError) {
error.message = `${error.message}\nFilename: ${packageJsonFilename}`;
}
throw error;
}

Expand Down

0 comments on commit 49d93a9

Please sign in to comment.