Skip to content

Commit

Permalink
chore: Provide the filename of the package.json file where the error …
Browse files Browse the repository at this point in the history
…occurred
  • Loading branch information
Adrian Zhang committed May 3, 2024
1 parent 0c41a82 commit 4c8d063
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 filename of the error 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 as Error).name === 'SyntaxError') {
error.message = `${error.message}\nFilename: ${packageJsonFilename}`;
}
throw error;
}

Expand Down

0 comments on commit 4c8d063

Please sign in to comment.