-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.ts
More file actions
33 lines (27 loc) · 994 Bytes
/
Copy patherrors.ts
File metadata and controls
33 lines (27 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Plan } from '../plan/plan.js';
export class ApplyValidationError extends Error {
resourceType: string;
resourceName?: string;
plan: Plan<any>;
logs: string[];
constructor(plan: Plan<any>, logs: string[] = []) {
super(`Failed to apply changes to resource: "${plan.resourceId}". Additional changes are needed to complete apply.\nChanges remaining:\n${ApplyValidationError.prettyPrintPlan(plan)}`);
this.resourceType = plan.coreParameters.type;
this.resourceName = plan.coreParameters.name;
this.plan = plan;
this.logs = logs;
}
private static prettyPrintPlan(plan: Plan<any>): string {
const { operation, parameters } = plan.toResponse();
const prettyParameters = parameters.map(({ name, operation, previousValue, newValue }) => ({
name,
operation,
currentValue: previousValue,
desiredValue: newValue,
}));
return JSON.stringify({
operation,
parameters: prettyParameters,
}, null, 2);
}
}