This repository was archived by the owner on Oct 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed
Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -42,12 +42,7 @@ export class TagMap {
4242 * @param tagMetadata The TagMetadata associated with this Tag.
4343 */
4444 set ( tagKey : TagKey , tagValue : TagValue , tagMetadata ?: TagMetadata ) : void {
45- if ( ! isValidTagKey ( tagKey ) ) {
46- throw new Error ( `Invalid TagKey name: ${ tagKey . name } ` ) ;
47- }
48- if ( ! isValidTagValue ( tagValue ) ) {
49- throw new Error ( `Invalid TagValue: ${ tagValue . value } ` ) ;
50- }
45+ if ( ! isValidTagKey ( tagKey ) || ! isValidTagValue ( tagValue ) ) return ;
5146 let existingKey ;
5247 for ( const key of this . registeredTags . keys ( ) ) {
5348 if ( key . name === tagKey . name ) {
Original file line number Diff line number Diff line change @@ -75,16 +75,16 @@ describe('TagMap()', () => {
7575 assert . deepStrictEqual ( tags . get ( key1 ) , expectedTagValueWithMetadata ) ;
7676 } ) ;
7777
78- it ( 'should throw an error when invalid tagKey' , ( ) => {
79- assert . throws ( ( ) => {
80- tagMap . set ( invalidKey1 , value1 ) ;
81- } , / ^ E r r o r : I n v a l i d T a g K e y n a m e : / ) ;
78+ it ( 'should silently ignore when invalid tagKey' , ( ) => {
79+ tagMap . set ( invalidKey1 , value1 ) ;
80+ const tags = tagMap . tagsWithMetadata ;
81+ assert . strictEqual ( tags . size , 0 ) ;
8282 } ) ;
8383
84- it ( 'should throw an error when invalid tagValue' , ( ) => {
85- assert . throws ( ( ) => {
86- tagMap . set ( key1 , invalidValue1 ) ;
87- } , / ^ E r r o r : I n v a l i d T a g V a l u e : / ) ;
84+ it ( 'should silently ignore when invalid tagValue' , ( ) => {
85+ tagMap . set ( key1 , invalidValue1 ) ;
86+ const tags = tagMap . tagsWithMetadata ;
87+ assert . strictEqual ( tags . size , 0 ) ;
8888 } ) ;
8989
9090 it ( 'should not set duplicate tagkey and tagvalue' , ( ) => {
You can’t perform that action at this time.
0 commit comments