Skip to content

Commit 6f0e90e

Browse files
committed
fix(@angular-devkit/architect): improve error message when configuration is missing
This commit makes the error message more actionable. Closes #29742
1 parent 2806932 commit 6f0e90e

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

packages/angular_devkit/architect/node/node-modules-architect-host.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
9090
}
9191

9292
if (!targetDefinition.configurations?.[configuration]) {
93-
throw new Error(`Configuration '${configuration}' is not set in the workspace.`);
93+
throw new Error(
94+
`Configuration '${configuration}' for target '${target}' in project '${project}' is not set in the workspace.`,
95+
);
9496
}
9597

9698
return (targetDefinition.configurations?.[configuration] ?? {}) as json.JsonObject;
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1+
import assert from 'node:assert';
12
import { ng } from '../../utils/process';
3+
import { expectToFail } from '../../utils/utils';
24

35
export default async function () {
4-
try {
5-
await ng('build', '--configuration', 'invalid');
6-
throw new Error('should have failed.');
7-
} catch (error) {
8-
if (
9-
!(
10-
error instanceof Error &&
11-
error.message.includes(`Configuration 'invalid' is not set in the workspace`)
12-
)
13-
) {
14-
throw error;
15-
}
16-
}
6+
const error = await expectToFail(() => ng('build', '--configuration', 'invalid'));
7+
assert.match(
8+
error.message,
9+
/Configuration 'invalid' for target 'build' in project 'test-project' is not set in the workspace/,
10+
);
1711
}

0 commit comments

Comments
 (0)