@@ -2,7 +2,7 @@ import { Construct } from 'constructs';
22import { IUserPoolAuthenticationProvider } from './identitypool-user-pool-authentication-provider' ;
33import { CfnIdentityPool , CfnIdentityPoolRoleAttachment , IUserPool , IUserPoolClient } from '../../aws-cognito' ;
44import { IOpenIdConnectProvider , ISamlProvider , Role , FederatedPrincipal , IRole } from '../../aws-iam' ;
5- import { Resource , IResource , Stack , ArnFormat , Lazy , Token } from '../../core' ;
5+ import { Resource , IResource , Stack , ArnFormat , Lazy , Token , ValidationError , UnscopedValidationError } from '../../core' ;
66import { addConstructMetadata , MethodMetadata } from '../../core/lib/metadata-resource' ;
77
88/**
@@ -383,15 +383,15 @@ export class IdentityPool extends Resource implements IIdentityPool {
383383 const pool = Stack . of ( scope ) . splitArn ( identityPoolArn , ArnFormat . SLASH_RESOURCE_NAME ) ;
384384 const res = pool . resourceName || '' ;
385385 if ( ! res ) {
386- throw new Error ( 'Invalid Identity Pool ARN' ) ;
386+ throw new ValidationError ( 'Invalid Identity Pool ARN' , scope ) ;
387387 }
388388 if ( ! Token . isUnresolved ( res ) ) {
389389 const idParts = res . split ( ':' ) ;
390390 if ( ! ( idParts . length === 2 ) ) {
391- throw new Error ( 'Invalid Identity Pool Id: Identity Pool Ids must follow the format <region>:<id>' ) ;
391+ throw new ValidationError ( 'Invalid Identity Pool Id: Identity Pool Ids must follow the format <region>:<id>' , scope ) ;
392392 }
393393 if ( ! Token . isUnresolved ( pool . region ) && idParts [ 0 ] !== pool . region ) {
394- throw new Error ( 'Invalid Identity Pool Id: Region in Identity Pool Id must match stack region' ) ;
394+ throw new ValidationError ( 'Invalid Identity Pool Id: Region in Identity Pool Id must match stack region' , scope ) ;
395395 }
396396 }
397397 class ImportedIdentityPool extends Resource implements IIdentityPool {
@@ -625,7 +625,7 @@ class IdentityPoolRoleAttachment extends Resource implements IIdentityPoolRoleAt
625625 } else {
626626 const providerUrl = prop . providerUrl . value ;
627627 if ( Token . isUnresolved ( providerUrl ) ) {
628- throw new Error ( 'mappingKey must be provided when providerUrl.value is a token' ) ;
628+ throw new UnscopedValidationError ( 'mappingKey must be provided when providerUrl.value is a token' ) ;
629629 }
630630 mappingKey = providerUrl ;
631631 }
@@ -637,7 +637,7 @@ class IdentityPoolRoleAttachment extends Resource implements IIdentityPoolRoleAt
637637 } ;
638638 if ( roleMapping . type === 'Rules' ) {
639639 if ( ! prop . rules ) {
640- throw new Error ( 'IdentityPoolRoleMapping.rules is required when useToken is false' ) ;
640+ throw new UnscopedValidationError ( 'IdentityPoolRoleMapping.rules is required when useToken is false' ) ;
641641 }
642642 roleMapping . rulesConfiguration = {
643643 rules : prop . rules . map ( rule => {
0 commit comments