Skip to content

Commit

Permalink
fix(@angular/cli): display a more detailed error message when workspa…
Browse files Browse the repository at this point in the history
…ce cannot be loaded

Closes #15023, closes #10757, closes #14933 and closes #11204
  • Loading branch information
alan-agius4 authored and kyliau committed Jul 9, 2019
1 parent 8e97df3 commit a57e986
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/angular/cli/utilities/config.ts
Expand Up @@ -78,7 +78,18 @@ export function getWorkspace(
new NodeJsSyncHost(),
);

workspace.loadWorkspaceFromHost(file).subscribe();
let error: unknown;
workspace.loadWorkspaceFromHost(file).subscribe({
error: e => error = e,
});

if (error) {
throw new Error(
`Workspace config file cannot le loaded: ${configPath}`
+ `\n${error instanceof Error ? error.message : error}`
)
}

cachedWorkspaces.set(level, workspace);

return workspace;
Expand Down Expand Up @@ -116,7 +127,7 @@ export function getWorkspaceRaw(
const ast = parseJsonAst(content, JsonParseMode.Loose);

if (ast.kind != 'object') {
throw new Error('Invalid JSON');
throw new Error(`Invalid JSON file: ${configPath}`);
}

return [ast, configPath];
Expand Down

0 comments on commit a57e986

Please sign in to comment.