File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
packages/aws-cdk-lib/core Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ export class Tag extends TagBase {
121
121
constructor ( key : string , value : string , props : TagProps = { } ) {
122
122
super ( key , props ) ;
123
123
if ( value === undefined ) {
124
- throw new UnscopedValidationError ( ' Tag must have a value' ) ;
124
+ throw new UnscopedValidationError ( ` Tag ' ${ key } ' must have a value` ) ;
125
125
}
126
126
this . value = value ;
127
127
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
13
13
ITaggable ,
14
14
ITaggableV2 ,
15
15
AspectPriority ,
16
+ UnscopedValidationError ,
16
17
} from '../lib' ;
17
18
import { synthesize } from '../lib/private/synthesis' ;
18
19
@@ -331,4 +332,14 @@ describe('tag aspect', () => {
331
332
} ) . toThrow ( ) ;
332
333
} ) ;
333
334
} ) ;
335
+
336
+ test ( 'if tag value is undefined, it raises with appropriate content' , ( ) => {
337
+ expect ( ( ) => {
338
+ new Tag ( 'test-key' , undefined as any ) ;
339
+ } ) . toThrow ( UnscopedValidationError ) ;
340
+
341
+ expect ( ( ) => {
342
+ new Tag ( 'test-key' , undefined as any ) ;
343
+ } ) . toThrow ( "Tag 'test-key' must have a value" ) ;
344
+ } ) ;
334
345
} ) ;
You can’t perform that action at this time.
0 commit comments