Skip to content

Commit 32feed1

Browse files
alan-agius4Keen Yee Liau
authored and
Keen Yee Liau
committed
fix(@angular/cli): display a more detailed error message when workspace cannot be loaded
Closes #15023, closes #10757, closes #14933 and closes #11204
1 parent 086f30c commit 32feed1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/angular/cli/utilities/config.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,18 @@ export function getWorkspace(
7878
new NodeJsSyncHost(),
7979
);
8080

81-
workspace.loadWorkspaceFromHost(file).subscribe();
81+
let error: unknown;
82+
workspace.loadWorkspaceFromHost(file).subscribe({
83+
error: e => error = e,
84+
});
85+
86+
if (error) {
87+
throw new Error(
88+
`Workspace config file cannot le loaded: ${configPath}`
89+
+ `\n${error instanceof Error ? error.message : error}`
90+
)
91+
}
92+
8293
cachedWorkspaces.set(level, workspace);
8394

8495
return workspace;
@@ -116,7 +127,7 @@ export function getWorkspaceRaw(
116127
const ast = parseJsonAst(content, JsonParseMode.Loose);
117128

118129
if (ast.kind != 'object') {
119-
throw new Error('Invalid JSON');
130+
throw new Error(`Invalid JSON file: ${configPath}`);
120131
}
121132

122133
return [ast, configPath];

0 commit comments

Comments
 (0)