Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/cli/cdk/toolkit-lib/wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CONFIG_DIR } from '../../../lib';
import { CDK_APP_ENTRY, CDK_PROJECT_DIR } from '../../constants';
import { getErrorMessage, isChangesetInProgressError } from '../../errors';
import { isChangesetInProgressError } from '../../errors';
import type { CdkToolkitWrapperOptions, DeployOptions, DestroyOptions, DiffOptions, ListOptions } from './types';
import {
BaseCredentials,
Expand Down Expand Up @@ -36,18 +36,10 @@ async function withErrorContext<T>(context: string, operation: () => Promise<T>)
try {
return await operation();
} catch (err) {
const message = getErrorMessage(err);
const stack = err instanceof Error ? err.stack : undefined;
const cause = err instanceof Error ? err.cause : undefined;

const error = new Error(`CDK ${context} failed: ${message}`);
if (stack) {
error.stack = `CDK ${context} failed: ${message}\n\nOriginal stack:\n${stack}`;
}
if (cause) {
error.cause = cause;
if (err instanceof Error) {
err.message = `CDK ${context} failed: ${err.message}`;
}
throw error;
throw err;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/deploy/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export async function handleDeploy(options: ValidatedDeployOptions): Promise<Dep
logger.finalize(false);
return {
success: false,
error: new Error(
error: new ValidationError(
'This will delete all deployed resources and the CloudFormation stack. Run with --yes to confirm teardown.'
),
logPath: logger.getRelativeLogPath(),
Expand Down
5 changes: 3 additions & 2 deletions src/cli/operations/deploy/preflight.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConfigIO, DOCKERFILE_NAME, getDockerfilePath, requireConfigRoot, resolveCodeLocation } from '../../../lib';
import { ValidationError } from '../../../lib/errors/types';
import type { AgentCoreProjectSpec, AwsDeploymentTarget } from '../../../schema';
import { validateAwsCredentials } from '../../aws/account';
import { LocalCdkProject } from '../../cdk/local-cdk-project';
Expand Down Expand Up @@ -109,7 +110,7 @@ export async function validateProject(): Promise<PreflightContext> {
// No deployed state file — no existing stack
}
if (!hasExistingStack) {
throw new Error(
throw new ValidationError(
'No resources defined in project. Add at least one resource (agent, memory, evaluator, or gateway) before deploying.'
);
}
Expand Down Expand Up @@ -144,7 +145,7 @@ function validateRuntimeNames(projectSpec: AgentCoreProjectSpec): void {
if (agentName) {
const combinedName = `${projectName}_${agentName}`;
if (combinedName.length > MAX_RUNTIME_NAME_LENGTH) {
throw new Error(
throw new ValidationError(
`Runtime name too long: "${combinedName}" (${combinedName.length} chars). ` +
`AWS limits runtime names to ${MAX_RUNTIME_NAME_LENGTH} characters. ` +
`Shorten the project name or agent name in agentcore.json.`
Expand Down
Loading