@@ -7,7 +7,7 @@ import { getHash } from './private/hash';
7
7
import { DeletionProtectionCheck } from './util' ;
8
8
import * as cloudwatch from '../../aws-cloudwatch' ;
9
9
import * as iam from '../../aws-iam' ;
10
- import { Resource , IResource , Stack , ArnFormat , PhysicalName , Names } from '../../core' ;
10
+ import { Resource , IResource , Stack , ArnFormat , PhysicalName , Names , ValidationError , UnscopedValidationError } from '../../core' ;
11
11
import { addConstructMetadata } from '../../core/lib/metadata-resource' ;
12
12
13
13
/**
@@ -56,7 +56,7 @@ abstract class EnvironmentBase extends Resource implements IEnvironment, IExtens
56
56
57
57
public addDeployment ( configuration : IConfiguration ) : void {
58
58
if ( this . name === undefined ) {
59
- throw new Error ( 'Environment name must be known to add a Deployment' ) ;
59
+ throw new ValidationError ( 'Environment name must be known to add a Deployment' , this ) ;
60
60
}
61
61
62
62
const queueSize = this . deploymentQueue . push (
@@ -203,12 +203,12 @@ export class Environment extends EnvironmentBase {
203
203
public static fromEnvironmentArn ( scope : Construct , id : string , environmentArn : string ) : IEnvironment {
204
204
const parsedArn = Stack . of ( scope ) . splitArn ( environmentArn , ArnFormat . SLASH_RESOURCE_NAME ) ;
205
205
if ( ! parsedArn . resourceName ) {
206
- throw new Error ( `Missing required /$/{applicationId}/environment//$/{environmentId} from environment ARN: ${ parsedArn . resourceName } ` ) ;
206
+ throw new ValidationError ( `Missing required /$/{applicationId}/environment//$/{environmentId} from environment ARN: ${ parsedArn . resourceName } ` , scope ) ;
207
207
}
208
208
209
209
const resourceName = parsedArn . resourceName . split ( '/' ) ;
210
210
if ( resourceName . length != 3 || ! resourceName [ 0 ] || ! resourceName [ 2 ] ) {
211
- throw new Error ( 'Missing required parameters for environment ARN: format should be /$/{applicationId}/environment//$/{environmentId}' ) ;
211
+ throw new ValidationError ( 'Missing required parameters for environment ARN: format should be /$/{applicationId}/environment//$/{environmentId}' , scope ) ;
212
212
}
213
213
214
214
const applicationId = resourceName [ 0 ] ;
@@ -413,7 +413,7 @@ export abstract class Monitor {
413
413
*/
414
414
public static fromCfnMonitorsProperty ( monitorsProperty : CfnEnvironment . MonitorsProperty ) : Monitor {
415
415
if ( monitorsProperty . alarmArn === undefined ) {
416
- throw new Error ( 'You must specify an alarmArn property to use "fromCfnMonitorsProperty".' ) ;
416
+ throw new UnscopedValidationError ( 'You must specify an alarmArn property to use "fromCfnMonitorsProperty".' ) ;
417
417
}
418
418
return {
419
419
alarmArn : monitorsProperty . alarmArn ,
0 commit comments