@aws-sdk/client-kms 3.50.0 → 3.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist-cjs/index.js +3 -0
  3. package/dist-cjs/models/KMSServiceException.js +11 -0
  4. package/dist-cjs/models/models_0.js +433 -3
  5. package/dist-cjs/protocols/Aws_json1_1.js +624 -2521
  6. package/dist-es/index.js +1 -0
  7. package/dist-es/models/KMSServiceException.js +12 -0
  8. package/dist-es/models/models_0.js +398 -1
  9. package/dist-es/protocols/Aws_json1_1.js +1320 -2648
  10. package/dist-types/index.d.ts +1 -0
  11. package/dist-types/models/KMSServiceException.d.ts +10 -0
  12. package/dist-types/models/models_0.d.ts +233 -133
  13. package/dist-types/ts3.4/KMS.d.ts +245 -0
  14. package/dist-types/ts3.4/KMSClient.d.ts +121 -0
  15. package/dist-types/ts3.4/commands/CancelKeyDeletionCommand.d.ts +17 -0
  16. package/dist-types/ts3.4/commands/ConnectCustomKeyStoreCommand.d.ts +17 -0
  17. package/dist-types/ts3.4/commands/CreateAliasCommand.d.ts +17 -0
  18. package/dist-types/ts3.4/commands/CreateCustomKeyStoreCommand.d.ts +17 -0
  19. package/dist-types/ts3.4/commands/CreateGrantCommand.d.ts +17 -0
  20. package/dist-types/ts3.4/commands/CreateKeyCommand.d.ts +17 -0
  21. package/dist-types/ts3.4/commands/DecryptCommand.d.ts +17 -0
  22. package/dist-types/ts3.4/commands/DeleteAliasCommand.d.ts +17 -0
  23. package/dist-types/ts3.4/commands/DeleteCustomKeyStoreCommand.d.ts +17 -0
  24. package/dist-types/ts3.4/commands/DeleteImportedKeyMaterialCommand.d.ts +17 -0
  25. package/dist-types/ts3.4/commands/DescribeCustomKeyStoresCommand.d.ts +17 -0
  26. package/dist-types/ts3.4/commands/DescribeKeyCommand.d.ts +17 -0
  27. package/dist-types/ts3.4/commands/DisableKeyCommand.d.ts +17 -0
  28. package/dist-types/ts3.4/commands/DisableKeyRotationCommand.d.ts +17 -0
  29. package/dist-types/ts3.4/commands/DisconnectCustomKeyStoreCommand.d.ts +17 -0
  30. package/dist-types/ts3.4/commands/EnableKeyCommand.d.ts +17 -0
  31. package/dist-types/ts3.4/commands/EnableKeyRotationCommand.d.ts +17 -0
  32. package/dist-types/ts3.4/commands/EncryptCommand.d.ts +17 -0
  33. package/dist-types/ts3.4/commands/GenerateDataKeyCommand.d.ts +17 -0
  34. package/dist-types/ts3.4/commands/GenerateDataKeyPairCommand.d.ts +17 -0
  35. package/dist-types/ts3.4/commands/GenerateDataKeyPairWithoutPlaintextCommand.d.ts +17 -0
  36. package/dist-types/ts3.4/commands/GenerateDataKeyWithoutPlaintextCommand.d.ts +17 -0
  37. package/dist-types/ts3.4/commands/GenerateRandomCommand.d.ts +17 -0
  38. package/dist-types/ts3.4/commands/GetKeyPolicyCommand.d.ts +17 -0
  39. package/dist-types/ts3.4/commands/GetKeyRotationStatusCommand.d.ts +17 -0
  40. package/dist-types/ts3.4/commands/GetParametersForImportCommand.d.ts +17 -0
  41. package/dist-types/ts3.4/commands/GetPublicKeyCommand.d.ts +17 -0
  42. package/dist-types/ts3.4/commands/ImportKeyMaterialCommand.d.ts +17 -0
  43. package/dist-types/ts3.4/commands/ListAliasesCommand.d.ts +17 -0
  44. package/dist-types/ts3.4/commands/ListGrantsCommand.d.ts +17 -0
  45. package/dist-types/ts3.4/commands/ListKeyPoliciesCommand.d.ts +17 -0
  46. package/dist-types/ts3.4/commands/ListKeysCommand.d.ts +17 -0
  47. package/dist-types/ts3.4/commands/ListResourceTagsCommand.d.ts +17 -0
  48. package/dist-types/ts3.4/commands/ListRetirableGrantsCommand.d.ts +17 -0
  49. package/dist-types/ts3.4/commands/PutKeyPolicyCommand.d.ts +17 -0
  50. package/dist-types/ts3.4/commands/ReEncryptCommand.d.ts +17 -0
  51. package/dist-types/ts3.4/commands/ReplicateKeyCommand.d.ts +17 -0
  52. package/dist-types/ts3.4/commands/RetireGrantCommand.d.ts +17 -0
  53. package/dist-types/ts3.4/commands/RevokeGrantCommand.d.ts +17 -0
  54. package/dist-types/ts3.4/commands/ScheduleKeyDeletionCommand.d.ts +17 -0
  55. package/dist-types/ts3.4/commands/SignCommand.d.ts +17 -0
  56. package/dist-types/ts3.4/commands/TagResourceCommand.d.ts +17 -0
  57. package/dist-types/ts3.4/commands/UntagResourceCommand.d.ts +17 -0
  58. package/dist-types/ts3.4/commands/UpdateAliasCommand.d.ts +17 -0
  59. package/dist-types/ts3.4/commands/UpdateCustomKeyStoreCommand.d.ts +17 -0
  60. package/dist-types/ts3.4/commands/UpdateKeyDescriptionCommand.d.ts +17 -0
  61. package/dist-types/ts3.4/commands/UpdatePrimaryRegionCommand.d.ts +17 -0
  62. package/dist-types/ts3.4/commands/VerifyCommand.d.ts +17 -0
  63. package/dist-types/ts3.4/commands/index.d.ts +48 -0
  64. package/dist-types/ts3.4/endpoints.d.ts +2 -0
  65. package/dist-types/ts3.4/index.d.ts +6 -0
  66. package/dist-types/ts3.4/models/KMSServiceException.d.ts +6 -0
  67. package/dist-types/ts3.4/models/index.d.ts +1 -0
  68. package/dist-types/ts3.4/models/models_0.d.ts +1484 -0
  69. package/dist-types/ts3.4/pagination/Interfaces.d.ts +6 -0
  70. package/dist-types/ts3.4/pagination/ListAliasesPaginator.d.ts +4 -0
  71. package/dist-types/ts3.4/pagination/ListGrantsPaginator.d.ts +4 -0
  72. package/dist-types/ts3.4/pagination/ListKeyPoliciesPaginator.d.ts +4 -0
  73. package/dist-types/ts3.4/pagination/ListKeysPaginator.d.ts +4 -0
  74. package/dist-types/ts3.4/pagination/index.d.ts +5 -0
  75. package/dist-types/ts3.4/protocols/Aws_json1_1.d.ts +146 -0
  76. package/dist-types/ts3.4/runtimeConfig.browser.d.ts +38 -0
  77. package/dist-types/ts3.4/runtimeConfig.d.ts +38 -0
  78. package/dist-types/ts3.4/runtimeConfig.native.d.ts +37 -0
  79. package/dist-types/ts3.4/runtimeConfig.shared.d.ts +11 -0
  80. package/package.json +33 -33
@@ -4,6 +4,8 @@ exports.deserializeAws_json1_1ConnectCustomKeyStoreCommand = exports.deserialize
4
4
  exports.deserializeAws_json1_1VerifyCommand = exports.deserializeAws_json1_1UpdatePrimaryRegionCommand = exports.deserializeAws_json1_1UpdateKeyDescriptionCommand = exports.deserializeAws_json1_1UpdateCustomKeyStoreCommand = exports.deserializeAws_json1_1UpdateAliasCommand = exports.deserializeAws_json1_1UntagResourceCommand = exports.deserializeAws_json1_1TagResourceCommand = exports.deserializeAws_json1_1SignCommand = exports.deserializeAws_json1_1ScheduleKeyDeletionCommand = exports.deserializeAws_json1_1RevokeGrantCommand = exports.deserializeAws_json1_1RetireGrantCommand = exports.deserializeAws_json1_1ReplicateKeyCommand = exports.deserializeAws_json1_1ReEncryptCommand = exports.deserializeAws_json1_1PutKeyPolicyCommand = exports.deserializeAws_json1_1ListRetirableGrantsCommand = exports.deserializeAws_json1_1ListResourceTagsCommand = exports.deserializeAws_json1_1ListKeysCommand = exports.deserializeAws_json1_1ListKeyPoliciesCommand = exports.deserializeAws_json1_1ListGrantsCommand = exports.deserializeAws_json1_1ListAliasesCommand = exports.deserializeAws_json1_1ImportKeyMaterialCommand = exports.deserializeAws_json1_1GetPublicKeyCommand = exports.deserializeAws_json1_1GetParametersForImportCommand = exports.deserializeAws_json1_1GetKeyRotationStatusCommand = exports.deserializeAws_json1_1GetKeyPolicyCommand = exports.deserializeAws_json1_1GenerateRandomCommand = exports.deserializeAws_json1_1GenerateDataKeyWithoutPlaintextCommand = exports.deserializeAws_json1_1GenerateDataKeyPairWithoutPlaintextCommand = exports.deserializeAws_json1_1GenerateDataKeyPairCommand = exports.deserializeAws_json1_1GenerateDataKeyCommand = exports.deserializeAws_json1_1EncryptCommand = exports.deserializeAws_json1_1EnableKeyRotationCommand = exports.deserializeAws_json1_1EnableKeyCommand = exports.deserializeAws_json1_1DisconnectCustomKeyStoreCommand = exports.deserializeAws_json1_1DisableKeyRotationCommand = exports.deserializeAws_json1_1DisableKeyCommand = exports.deserializeAws_json1_1DescribeKeyCommand = exports.deserializeAws_json1_1DescribeCustomKeyStoresCommand = exports.deserializeAws_json1_1DeleteImportedKeyMaterialCommand = exports.deserializeAws_json1_1DeleteCustomKeyStoreCommand = exports.deserializeAws_json1_1DeleteAliasCommand = exports.deserializeAws_json1_1DecryptCommand = exports.deserializeAws_json1_1CreateKeyCommand = exports.deserializeAws_json1_1CreateGrantCommand = exports.deserializeAws_json1_1CreateCustomKeyStoreCommand = exports.deserializeAws_json1_1CreateAliasCommand = void 0;
5
5
  const protocol_http_1 = require("@aws-sdk/protocol-http");
6
6
  const smithy_client_1 = require("@aws-sdk/smithy-client");
7
+ const KMSServiceException_1 = require("../models/KMSServiceException");
8
+ const models_0_1 = require("../models/models_0");
7
9
  const serializeAws_json1_1CancelKeyDeletionCommand = async (input, context) => {
8
10
  const headers = {
9
11
  "content-type": "application/x-amz-json-1.1",
@@ -509,59 +511,28 @@ const deserializeAws_json1_1CancelKeyDeletionCommandError = async (output, conte
509
511
  switch (errorCode) {
510
512
  case "DependencyTimeoutException":
511
513
  case "com.amazonaws.kms#DependencyTimeoutException":
512
- response = {
513
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
514
- name: errorCode,
515
- $metadata: deserializeMetadata(output),
516
- };
517
- break;
514
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
518
515
  case "InvalidArnException":
519
516
  case "com.amazonaws.kms#InvalidArnException":
520
- response = {
521
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
522
- name: errorCode,
523
- $metadata: deserializeMetadata(output),
524
- };
525
- break;
517
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
526
518
  case "KMSInternalException":
527
519
  case "com.amazonaws.kms#KMSInternalException":
528
- response = {
529
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
530
- name: errorCode,
531
- $metadata: deserializeMetadata(output),
532
- };
533
- break;
520
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
534
521
  case "KMSInvalidStateException":
535
522
  case "com.amazonaws.kms#KMSInvalidStateException":
536
- response = {
537
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
538
- name: errorCode,
539
- $metadata: deserializeMetadata(output),
540
- };
541
- break;
523
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
542
524
  case "NotFoundException":
543
525
  case "com.amazonaws.kms#NotFoundException":
544
- response = {
545
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
546
- name: errorCode,
547
- $metadata: deserializeMetadata(output),
548
- };
549
- break;
526
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
550
527
  default:
551
528
  const parsedBody = parsedOutput.body;
552
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
553
- response = {
554
- ...parsedBody,
555
- name: `${errorCode}`,
556
- message: parsedBody.message || parsedBody.Message || errorCode,
529
+ response = new KMSServiceException_1.KMSServiceException({
530
+ name: parsedBody.code || parsedBody.Code || errorCode,
557
531
  $fault: "client",
558
532
  $metadata: deserializeMetadata(output),
559
- };
533
+ });
534
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
560
535
  }
561
- const message = response.message || response.Message || errorCode;
562
- response.message = message;
563
- delete response.Message;
564
- return Promise.reject(Object.assign(new Error(message), response));
565
536
  };
566
537
  const deserializeAws_json1_1ConnectCustomKeyStoreCommand = async (output, context) => {
567
538
  if (output.statusCode >= 300) {
@@ -588,59 +559,28 @@ const deserializeAws_json1_1ConnectCustomKeyStoreCommandError = async (output, c
588
559
  switch (errorCode) {
589
560
  case "CloudHsmClusterInvalidConfigurationException":
590
561
  case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException":
591
- response = {
592
- ...(await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse(parsedOutput, context)),
593
- name: errorCode,
594
- $metadata: deserializeMetadata(output),
595
- };
596
- break;
562
+ throw await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse(parsedOutput, context);
597
563
  case "CloudHsmClusterNotActiveException":
598
564
  case "com.amazonaws.kms#CloudHsmClusterNotActiveException":
599
- response = {
600
- ...(await deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse(parsedOutput, context)),
601
- name: errorCode,
602
- $metadata: deserializeMetadata(output),
603
- };
604
- break;
565
+ throw await deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse(parsedOutput, context);
605
566
  case "CustomKeyStoreInvalidStateException":
606
567
  case "com.amazonaws.kms#CustomKeyStoreInvalidStateException":
607
- response = {
608
- ...(await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context)),
609
- name: errorCode,
610
- $metadata: deserializeMetadata(output),
611
- };
612
- break;
568
+ throw await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context);
613
569
  case "CustomKeyStoreNotFoundException":
614
570
  case "com.amazonaws.kms#CustomKeyStoreNotFoundException":
615
- response = {
616
- ...(await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context)),
617
- name: errorCode,
618
- $metadata: deserializeMetadata(output),
619
- };
620
- break;
571
+ throw await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context);
621
572
  case "KMSInternalException":
622
573
  case "com.amazonaws.kms#KMSInternalException":
623
- response = {
624
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
625
- name: errorCode,
626
- $metadata: deserializeMetadata(output),
627
- };
628
- break;
574
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
629
575
  default:
630
576
  const parsedBody = parsedOutput.body;
631
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
632
- response = {
633
- ...parsedBody,
634
- name: `${errorCode}`,
635
- message: parsedBody.message || parsedBody.Message || errorCode,
577
+ response = new KMSServiceException_1.KMSServiceException({
578
+ name: parsedBody.code || parsedBody.Code || errorCode,
636
579
  $fault: "client",
637
580
  $metadata: deserializeMetadata(output),
638
- };
581
+ });
582
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
639
583
  }
640
- const message = response.message || response.Message || errorCode;
641
- response.message = message;
642
- delete response.Message;
643
- return Promise.reject(Object.assign(new Error(message), response));
644
584
  };
645
585
  const deserializeAws_json1_1CreateAliasCommand = async (output, context) => {
646
586
  if (output.statusCode >= 300) {
@@ -664,75 +604,34 @@ const deserializeAws_json1_1CreateAliasCommandError = async (output, context) =>
664
604
  switch (errorCode) {
665
605
  case "AlreadyExistsException":
666
606
  case "com.amazonaws.kms#AlreadyExistsException":
667
- response = {
668
- ...(await deserializeAws_json1_1AlreadyExistsExceptionResponse(parsedOutput, context)),
669
- name: errorCode,
670
- $metadata: deserializeMetadata(output),
671
- };
672
- break;
607
+ throw await deserializeAws_json1_1AlreadyExistsExceptionResponse(parsedOutput, context);
673
608
  case "DependencyTimeoutException":
674
609
  case "com.amazonaws.kms#DependencyTimeoutException":
675
- response = {
676
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
677
- name: errorCode,
678
- $metadata: deserializeMetadata(output),
679
- };
680
- break;
610
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
681
611
  case "InvalidAliasNameException":
682
612
  case "com.amazonaws.kms#InvalidAliasNameException":
683
- response = {
684
- ...(await deserializeAws_json1_1InvalidAliasNameExceptionResponse(parsedOutput, context)),
685
- name: errorCode,
686
- $metadata: deserializeMetadata(output),
687
- };
688
- break;
613
+ throw await deserializeAws_json1_1InvalidAliasNameExceptionResponse(parsedOutput, context);
689
614
  case "KMSInternalException":
690
615
  case "com.amazonaws.kms#KMSInternalException":
691
- response = {
692
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
693
- name: errorCode,
694
- $metadata: deserializeMetadata(output),
695
- };
696
- break;
616
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
697
617
  case "KMSInvalidStateException":
698
618
  case "com.amazonaws.kms#KMSInvalidStateException":
699
- response = {
700
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
701
- name: errorCode,
702
- $metadata: deserializeMetadata(output),
703
- };
704
- break;
619
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
705
620
  case "LimitExceededException":
706
621
  case "com.amazonaws.kms#LimitExceededException":
707
- response = {
708
- ...(await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context)),
709
- name: errorCode,
710
- $metadata: deserializeMetadata(output),
711
- };
712
- break;
622
+ throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context);
713
623
  case "NotFoundException":
714
624
  case "com.amazonaws.kms#NotFoundException":
715
- response = {
716
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
717
- name: errorCode,
718
- $metadata: deserializeMetadata(output),
719
- };
720
- break;
625
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
721
626
  default:
722
627
  const parsedBody = parsedOutput.body;
723
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
724
- response = {
725
- ...parsedBody,
726
- name: `${errorCode}`,
727
- message: parsedBody.message || parsedBody.Message || errorCode,
628
+ response = new KMSServiceException_1.KMSServiceException({
629
+ name: parsedBody.code || parsedBody.Code || errorCode,
728
630
  $fault: "client",
729
631
  $metadata: deserializeMetadata(output),
730
- };
632
+ });
633
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
731
634
  }
732
- const message = response.message || response.Message || errorCode;
733
- response.message = message;
734
- delete response.Message;
735
- return Promise.reject(Object.assign(new Error(message), response));
736
635
  };
737
636
  const deserializeAws_json1_1CreateCustomKeyStoreCommand = async (output, context) => {
738
637
  if (output.statusCode >= 300) {
@@ -759,75 +658,34 @@ const deserializeAws_json1_1CreateCustomKeyStoreCommandError = async (output, co
759
658
  switch (errorCode) {
760
659
  case "CloudHsmClusterInUseException":
761
660
  case "com.amazonaws.kms#CloudHsmClusterInUseException":
762
- response = {
763
- ...(await deserializeAws_json1_1CloudHsmClusterInUseExceptionResponse(parsedOutput, context)),
764
- name: errorCode,
765
- $metadata: deserializeMetadata(output),
766
- };
767
- break;
661
+ throw await deserializeAws_json1_1CloudHsmClusterInUseExceptionResponse(parsedOutput, context);
768
662
  case "CloudHsmClusterInvalidConfigurationException":
769
663
  case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException":
770
- response = {
771
- ...(await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse(parsedOutput, context)),
772
- name: errorCode,
773
- $metadata: deserializeMetadata(output),
774
- };
775
- break;
664
+ throw await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse(parsedOutput, context);
776
665
  case "CloudHsmClusterNotActiveException":
777
666
  case "com.amazonaws.kms#CloudHsmClusterNotActiveException":
778
- response = {
779
- ...(await deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse(parsedOutput, context)),
780
- name: errorCode,
781
- $metadata: deserializeMetadata(output),
782
- };
783
- break;
667
+ throw await deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse(parsedOutput, context);
784
668
  case "CloudHsmClusterNotFoundException":
785
669
  case "com.amazonaws.kms#CloudHsmClusterNotFoundException":
786
- response = {
787
- ...(await deserializeAws_json1_1CloudHsmClusterNotFoundExceptionResponse(parsedOutput, context)),
788
- name: errorCode,
789
- $metadata: deserializeMetadata(output),
790
- };
791
- break;
670
+ throw await deserializeAws_json1_1CloudHsmClusterNotFoundExceptionResponse(parsedOutput, context);
792
671
  case "CustomKeyStoreNameInUseException":
793
672
  case "com.amazonaws.kms#CustomKeyStoreNameInUseException":
794
- response = {
795
- ...(await deserializeAws_json1_1CustomKeyStoreNameInUseExceptionResponse(parsedOutput, context)),
796
- name: errorCode,
797
- $metadata: deserializeMetadata(output),
798
- };
799
- break;
673
+ throw await deserializeAws_json1_1CustomKeyStoreNameInUseExceptionResponse(parsedOutput, context);
800
674
  case "IncorrectTrustAnchorException":
801
675
  case "com.amazonaws.kms#IncorrectTrustAnchorException":
802
- response = {
803
- ...(await deserializeAws_json1_1IncorrectTrustAnchorExceptionResponse(parsedOutput, context)),
804
- name: errorCode,
805
- $metadata: deserializeMetadata(output),
806
- };
807
- break;
676
+ throw await deserializeAws_json1_1IncorrectTrustAnchorExceptionResponse(parsedOutput, context);
808
677
  case "KMSInternalException":
809
678
  case "com.amazonaws.kms#KMSInternalException":
810
- response = {
811
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
812
- name: errorCode,
813
- $metadata: deserializeMetadata(output),
814
- };
815
- break;
679
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
816
680
  default:
817
681
  const parsedBody = parsedOutput.body;
818
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
819
- response = {
820
- ...parsedBody,
821
- name: `${errorCode}`,
822
- message: parsedBody.message || parsedBody.Message || errorCode,
682
+ response = new KMSServiceException_1.KMSServiceException({
683
+ name: parsedBody.code || parsedBody.Code || errorCode,
823
684
  $fault: "client",
824
685
  $metadata: deserializeMetadata(output),
825
- };
686
+ });
687
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
826
688
  }
827
- const message = response.message || response.Message || errorCode;
828
- response.message = message;
829
- delete response.Message;
830
- return Promise.reject(Object.assign(new Error(message), response));
831
689
  };
832
690
  const deserializeAws_json1_1CreateGrantCommand = async (output, context) => {
833
691
  if (output.statusCode >= 300) {
@@ -854,83 +712,37 @@ const deserializeAws_json1_1CreateGrantCommandError = async (output, context) =>
854
712
  switch (errorCode) {
855
713
  case "DependencyTimeoutException":
856
714
  case "com.amazonaws.kms#DependencyTimeoutException":
857
- response = {
858
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
859
- name: errorCode,
860
- $metadata: deserializeMetadata(output),
861
- };
862
- break;
715
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
863
716
  case "DisabledException":
864
717
  case "com.amazonaws.kms#DisabledException":
865
- response = {
866
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
867
- name: errorCode,
868
- $metadata: deserializeMetadata(output),
869
- };
870
- break;
718
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
871
719
  case "InvalidArnException":
872
720
  case "com.amazonaws.kms#InvalidArnException":
873
- response = {
874
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
875
- name: errorCode,
876
- $metadata: deserializeMetadata(output),
877
- };
878
- break;
721
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
879
722
  case "InvalidGrantTokenException":
880
723
  case "com.amazonaws.kms#InvalidGrantTokenException":
881
- response = {
882
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
883
- name: errorCode,
884
- $metadata: deserializeMetadata(output),
885
- };
886
- break;
724
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
887
725
  case "KMSInternalException":
888
726
  case "com.amazonaws.kms#KMSInternalException":
889
- response = {
890
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
891
- name: errorCode,
892
- $metadata: deserializeMetadata(output),
893
- };
894
- break;
727
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
895
728
  case "KMSInvalidStateException":
896
729
  case "com.amazonaws.kms#KMSInvalidStateException":
897
- response = {
898
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
899
- name: errorCode,
900
- $metadata: deserializeMetadata(output),
901
- };
902
- break;
730
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
903
731
  case "LimitExceededException":
904
732
  case "com.amazonaws.kms#LimitExceededException":
905
- response = {
906
- ...(await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context)),
907
- name: errorCode,
908
- $metadata: deserializeMetadata(output),
909
- };
910
- break;
733
+ throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context);
911
734
  case "NotFoundException":
912
735
  case "com.amazonaws.kms#NotFoundException":
913
- response = {
914
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
915
- name: errorCode,
916
- $metadata: deserializeMetadata(output),
917
- };
918
- break;
736
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
919
737
  default:
920
738
  const parsedBody = parsedOutput.body;
921
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
922
- response = {
923
- ...parsedBody,
924
- name: `${errorCode}`,
925
- message: parsedBody.message || parsedBody.Message || errorCode,
739
+ response = new KMSServiceException_1.KMSServiceException({
740
+ name: parsedBody.code || parsedBody.Code || errorCode,
926
741
  $fault: "client",
927
742
  $metadata: deserializeMetadata(output),
928
- };
743
+ });
744
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
929
745
  }
930
- const message = response.message || response.Message || errorCode;
931
- response.message = message;
932
- delete response.Message;
933
- return Promise.reject(Object.assign(new Error(message), response));
934
746
  };
935
747
  const deserializeAws_json1_1CreateKeyCommand = async (output, context) => {
936
748
  if (output.statusCode >= 300) {
@@ -957,99 +769,43 @@ const deserializeAws_json1_1CreateKeyCommandError = async (output, context) => {
957
769
  switch (errorCode) {
958
770
  case "CloudHsmClusterInvalidConfigurationException":
959
771
  case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException":
960
- response = {
961
- ...(await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse(parsedOutput, context)),
962
- name: errorCode,
963
- $metadata: deserializeMetadata(output),
964
- };
965
- break;
772
+ throw await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse(parsedOutput, context);
966
773
  case "CustomKeyStoreInvalidStateException":
967
774
  case "com.amazonaws.kms#CustomKeyStoreInvalidStateException":
968
- response = {
969
- ...(await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context)),
970
- name: errorCode,
971
- $metadata: deserializeMetadata(output),
972
- };
973
- break;
775
+ throw await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context);
974
776
  case "CustomKeyStoreNotFoundException":
975
777
  case "com.amazonaws.kms#CustomKeyStoreNotFoundException":
976
- response = {
977
- ...(await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context)),
978
- name: errorCode,
979
- $metadata: deserializeMetadata(output),
980
- };
981
- break;
778
+ throw await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context);
982
779
  case "DependencyTimeoutException":
983
780
  case "com.amazonaws.kms#DependencyTimeoutException":
984
- response = {
985
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
986
- name: errorCode,
987
- $metadata: deserializeMetadata(output),
988
- };
989
- break;
781
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
990
782
  case "InvalidArnException":
991
783
  case "com.amazonaws.kms#InvalidArnException":
992
- response = {
993
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
994
- name: errorCode,
995
- $metadata: deserializeMetadata(output),
996
- };
997
- break;
784
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
998
785
  case "KMSInternalException":
999
786
  case "com.amazonaws.kms#KMSInternalException":
1000
- response = {
1001
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1002
- name: errorCode,
1003
- $metadata: deserializeMetadata(output),
1004
- };
1005
- break;
787
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1006
788
  case "LimitExceededException":
1007
789
  case "com.amazonaws.kms#LimitExceededException":
1008
- response = {
1009
- ...(await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context)),
1010
- name: errorCode,
1011
- $metadata: deserializeMetadata(output),
1012
- };
1013
- break;
790
+ throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context);
1014
791
  case "MalformedPolicyDocumentException":
1015
792
  case "com.amazonaws.kms#MalformedPolicyDocumentException":
1016
- response = {
1017
- ...(await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse(parsedOutput, context)),
1018
- name: errorCode,
1019
- $metadata: deserializeMetadata(output),
1020
- };
1021
- break;
793
+ throw await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse(parsedOutput, context);
1022
794
  case "TagException":
1023
795
  case "com.amazonaws.kms#TagException":
1024
- response = {
1025
- ...(await deserializeAws_json1_1TagExceptionResponse(parsedOutput, context)),
1026
- name: errorCode,
1027
- $metadata: deserializeMetadata(output),
1028
- };
1029
- break;
796
+ throw await deserializeAws_json1_1TagExceptionResponse(parsedOutput, context);
1030
797
  case "UnsupportedOperationException":
1031
798
  case "com.amazonaws.kms#UnsupportedOperationException":
1032
- response = {
1033
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
1034
- name: errorCode,
1035
- $metadata: deserializeMetadata(output),
1036
- };
1037
- break;
799
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
1038
800
  default:
1039
801
  const parsedBody = parsedOutput.body;
1040
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1041
- response = {
1042
- ...parsedBody,
1043
- name: `${errorCode}`,
1044
- message: parsedBody.message || parsedBody.Message || errorCode,
802
+ response = new KMSServiceException_1.KMSServiceException({
803
+ name: parsedBody.code || parsedBody.Code || errorCode,
1045
804
  $fault: "client",
1046
805
  $metadata: deserializeMetadata(output),
1047
- };
806
+ });
807
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1048
808
  }
1049
- const message = response.message || response.Message || errorCode;
1050
- response.message = message;
1051
- delete response.Message;
1052
- return Promise.reject(Object.assign(new Error(message), response));
1053
809
  };
1054
810
  const deserializeAws_json1_1DecryptCommand = async (output, context) => {
1055
811
  if (output.statusCode >= 300) {
@@ -1076,99 +832,43 @@ const deserializeAws_json1_1DecryptCommandError = async (output, context) => {
1076
832
  switch (errorCode) {
1077
833
  case "DependencyTimeoutException":
1078
834
  case "com.amazonaws.kms#DependencyTimeoutException":
1079
- response = {
1080
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
1081
- name: errorCode,
1082
- $metadata: deserializeMetadata(output),
1083
- };
1084
- break;
835
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
1085
836
  case "DisabledException":
1086
837
  case "com.amazonaws.kms#DisabledException":
1087
- response = {
1088
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
1089
- name: errorCode,
1090
- $metadata: deserializeMetadata(output),
1091
- };
1092
- break;
838
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
1093
839
  case "IncorrectKeyException":
1094
840
  case "com.amazonaws.kms#IncorrectKeyException":
1095
- response = {
1096
- ...(await deserializeAws_json1_1IncorrectKeyExceptionResponse(parsedOutput, context)),
1097
- name: errorCode,
1098
- $metadata: deserializeMetadata(output),
1099
- };
1100
- break;
841
+ throw await deserializeAws_json1_1IncorrectKeyExceptionResponse(parsedOutput, context);
1101
842
  case "InvalidCiphertextException":
1102
843
  case "com.amazonaws.kms#InvalidCiphertextException":
1103
- response = {
1104
- ...(await deserializeAws_json1_1InvalidCiphertextExceptionResponse(parsedOutput, context)),
1105
- name: errorCode,
1106
- $metadata: deserializeMetadata(output),
1107
- };
1108
- break;
844
+ throw await deserializeAws_json1_1InvalidCiphertextExceptionResponse(parsedOutput, context);
1109
845
  case "InvalidGrantTokenException":
1110
846
  case "com.amazonaws.kms#InvalidGrantTokenException":
1111
- response = {
1112
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
1113
- name: errorCode,
1114
- $metadata: deserializeMetadata(output),
1115
- };
1116
- break;
847
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
1117
848
  case "InvalidKeyUsageException":
1118
849
  case "com.amazonaws.kms#InvalidKeyUsageException":
1119
- response = {
1120
- ...(await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context)),
1121
- name: errorCode,
1122
- $metadata: deserializeMetadata(output),
1123
- };
1124
- break;
850
+ throw await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context);
1125
851
  case "KeyUnavailableException":
1126
852
  case "com.amazonaws.kms#KeyUnavailableException":
1127
- response = {
1128
- ...(await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context)),
1129
- name: errorCode,
1130
- $metadata: deserializeMetadata(output),
1131
- };
1132
- break;
853
+ throw await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context);
1133
854
  case "KMSInternalException":
1134
855
  case "com.amazonaws.kms#KMSInternalException":
1135
- response = {
1136
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1137
- name: errorCode,
1138
- $metadata: deserializeMetadata(output),
1139
- };
1140
- break;
856
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1141
857
  case "KMSInvalidStateException":
1142
858
  case "com.amazonaws.kms#KMSInvalidStateException":
1143
- response = {
1144
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
1145
- name: errorCode,
1146
- $metadata: deserializeMetadata(output),
1147
- };
1148
- break;
859
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
1149
860
  case "NotFoundException":
1150
861
  case "com.amazonaws.kms#NotFoundException":
1151
- response = {
1152
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
1153
- name: errorCode,
1154
- $metadata: deserializeMetadata(output),
1155
- };
1156
- break;
862
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
1157
863
  default:
1158
864
  const parsedBody = parsedOutput.body;
1159
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1160
- response = {
1161
- ...parsedBody,
1162
- name: `${errorCode}`,
1163
- message: parsedBody.message || parsedBody.Message || errorCode,
865
+ response = new KMSServiceException_1.KMSServiceException({
866
+ name: parsedBody.code || parsedBody.Code || errorCode,
1164
867
  $fault: "client",
1165
868
  $metadata: deserializeMetadata(output),
1166
- };
869
+ });
870
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1167
871
  }
1168
- const message = response.message || response.Message || errorCode;
1169
- response.message = message;
1170
- delete response.Message;
1171
- return Promise.reject(Object.assign(new Error(message), response));
1172
872
  };
1173
873
  const deserializeAws_json1_1DeleteAliasCommand = async (output, context) => {
1174
874
  if (output.statusCode >= 300) {
@@ -1192,51 +892,25 @@ const deserializeAws_json1_1DeleteAliasCommandError = async (output, context) =>
1192
892
  switch (errorCode) {
1193
893
  case "DependencyTimeoutException":
1194
894
  case "com.amazonaws.kms#DependencyTimeoutException":
1195
- response = {
1196
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
1197
- name: errorCode,
1198
- $metadata: deserializeMetadata(output),
1199
- };
1200
- break;
895
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
1201
896
  case "KMSInternalException":
1202
897
  case "com.amazonaws.kms#KMSInternalException":
1203
- response = {
1204
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1205
- name: errorCode,
1206
- $metadata: deserializeMetadata(output),
1207
- };
1208
- break;
898
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1209
899
  case "KMSInvalidStateException":
1210
900
  case "com.amazonaws.kms#KMSInvalidStateException":
1211
- response = {
1212
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
1213
- name: errorCode,
1214
- $metadata: deserializeMetadata(output),
1215
- };
1216
- break;
901
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
1217
902
  case "NotFoundException":
1218
903
  case "com.amazonaws.kms#NotFoundException":
1219
- response = {
1220
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
1221
- name: errorCode,
1222
- $metadata: deserializeMetadata(output),
1223
- };
1224
- break;
904
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
1225
905
  default:
1226
906
  const parsedBody = parsedOutput.body;
1227
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1228
- response = {
1229
- ...parsedBody,
1230
- name: `${errorCode}`,
1231
- message: parsedBody.message || parsedBody.Message || errorCode,
907
+ response = new KMSServiceException_1.KMSServiceException({
908
+ name: parsedBody.code || parsedBody.Code || errorCode,
1232
909
  $fault: "client",
1233
910
  $metadata: deserializeMetadata(output),
1234
- };
911
+ });
912
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1235
913
  }
1236
- const message = response.message || response.Message || errorCode;
1237
- response.message = message;
1238
- delete response.Message;
1239
- return Promise.reject(Object.assign(new Error(message), response));
1240
914
  };
1241
915
  const deserializeAws_json1_1DeleteCustomKeyStoreCommand = async (output, context) => {
1242
916
  if (output.statusCode >= 300) {
@@ -1263,51 +937,25 @@ const deserializeAws_json1_1DeleteCustomKeyStoreCommandError = async (output, co
1263
937
  switch (errorCode) {
1264
938
  case "CustomKeyStoreHasCMKsException":
1265
939
  case "com.amazonaws.kms#CustomKeyStoreHasCMKsException":
1266
- response = {
1267
- ...(await deserializeAws_json1_1CustomKeyStoreHasCMKsExceptionResponse(parsedOutput, context)),
1268
- name: errorCode,
1269
- $metadata: deserializeMetadata(output),
1270
- };
1271
- break;
940
+ throw await deserializeAws_json1_1CustomKeyStoreHasCMKsExceptionResponse(parsedOutput, context);
1272
941
  case "CustomKeyStoreInvalidStateException":
1273
942
  case "com.amazonaws.kms#CustomKeyStoreInvalidStateException":
1274
- response = {
1275
- ...(await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context)),
1276
- name: errorCode,
1277
- $metadata: deserializeMetadata(output),
1278
- };
1279
- break;
943
+ throw await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context);
1280
944
  case "CustomKeyStoreNotFoundException":
1281
945
  case "com.amazonaws.kms#CustomKeyStoreNotFoundException":
1282
- response = {
1283
- ...(await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context)),
1284
- name: errorCode,
1285
- $metadata: deserializeMetadata(output),
1286
- };
1287
- break;
946
+ throw await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context);
1288
947
  case "KMSInternalException":
1289
948
  case "com.amazonaws.kms#KMSInternalException":
1290
- response = {
1291
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1292
- name: errorCode,
1293
- $metadata: deserializeMetadata(output),
1294
- };
1295
- break;
949
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1296
950
  default:
1297
951
  const parsedBody = parsedOutput.body;
1298
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1299
- response = {
1300
- ...parsedBody,
1301
- name: `${errorCode}`,
1302
- message: parsedBody.message || parsedBody.Message || errorCode,
952
+ response = new KMSServiceException_1.KMSServiceException({
953
+ name: parsedBody.code || parsedBody.Code || errorCode,
1303
954
  $fault: "client",
1304
955
  $metadata: deserializeMetadata(output),
1305
- };
956
+ });
957
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1306
958
  }
1307
- const message = response.message || response.Message || errorCode;
1308
- response.message = message;
1309
- delete response.Message;
1310
- return Promise.reject(Object.assign(new Error(message), response));
1311
959
  };
1312
960
  const deserializeAws_json1_1DeleteImportedKeyMaterialCommand = async (output, context) => {
1313
961
  if (output.statusCode >= 300) {
@@ -1331,67 +979,31 @@ const deserializeAws_json1_1DeleteImportedKeyMaterialCommandError = async (outpu
1331
979
  switch (errorCode) {
1332
980
  case "DependencyTimeoutException":
1333
981
  case "com.amazonaws.kms#DependencyTimeoutException":
1334
- response = {
1335
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
1336
- name: errorCode,
1337
- $metadata: deserializeMetadata(output),
1338
- };
1339
- break;
982
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
1340
983
  case "InvalidArnException":
1341
984
  case "com.amazonaws.kms#InvalidArnException":
1342
- response = {
1343
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
1344
- name: errorCode,
1345
- $metadata: deserializeMetadata(output),
1346
- };
1347
- break;
985
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
1348
986
  case "KMSInternalException":
1349
987
  case "com.amazonaws.kms#KMSInternalException":
1350
- response = {
1351
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1352
- name: errorCode,
1353
- $metadata: deserializeMetadata(output),
1354
- };
1355
- break;
988
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1356
989
  case "KMSInvalidStateException":
1357
990
  case "com.amazonaws.kms#KMSInvalidStateException":
1358
- response = {
1359
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
1360
- name: errorCode,
1361
- $metadata: deserializeMetadata(output),
1362
- };
1363
- break;
991
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
1364
992
  case "NotFoundException":
1365
993
  case "com.amazonaws.kms#NotFoundException":
1366
- response = {
1367
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
1368
- name: errorCode,
1369
- $metadata: deserializeMetadata(output),
1370
- };
1371
- break;
994
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
1372
995
  case "UnsupportedOperationException":
1373
996
  case "com.amazonaws.kms#UnsupportedOperationException":
1374
- response = {
1375
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
1376
- name: errorCode,
1377
- $metadata: deserializeMetadata(output),
1378
- };
1379
- break;
997
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
1380
998
  default:
1381
999
  const parsedBody = parsedOutput.body;
1382
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1383
- response = {
1384
- ...parsedBody,
1385
- name: `${errorCode}`,
1386
- message: parsedBody.message || parsedBody.Message || errorCode,
1000
+ response = new KMSServiceException_1.KMSServiceException({
1001
+ name: parsedBody.code || parsedBody.Code || errorCode,
1387
1002
  $fault: "client",
1388
1003
  $metadata: deserializeMetadata(output),
1389
- };
1004
+ });
1005
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1390
1006
  }
1391
- const message = response.message || response.Message || errorCode;
1392
- response.message = message;
1393
- delete response.Message;
1394
- return Promise.reject(Object.assign(new Error(message), response));
1395
1007
  };
1396
1008
  const deserializeAws_json1_1DescribeCustomKeyStoresCommand = async (output, context) => {
1397
1009
  if (output.statusCode >= 300) {
@@ -1418,43 +1030,22 @@ const deserializeAws_json1_1DescribeCustomKeyStoresCommandError = async (output,
1418
1030
  switch (errorCode) {
1419
1031
  case "CustomKeyStoreNotFoundException":
1420
1032
  case "com.amazonaws.kms#CustomKeyStoreNotFoundException":
1421
- response = {
1422
- ...(await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context)),
1423
- name: errorCode,
1424
- $metadata: deserializeMetadata(output),
1425
- };
1426
- break;
1033
+ throw await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context);
1427
1034
  case "InvalidMarkerException":
1428
1035
  case "com.amazonaws.kms#InvalidMarkerException":
1429
- response = {
1430
- ...(await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context)),
1431
- name: errorCode,
1432
- $metadata: deserializeMetadata(output),
1433
- };
1434
- break;
1036
+ throw await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context);
1435
1037
  case "KMSInternalException":
1436
1038
  case "com.amazonaws.kms#KMSInternalException":
1437
- response = {
1438
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1439
- name: errorCode,
1440
- $metadata: deserializeMetadata(output),
1441
- };
1442
- break;
1039
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1443
1040
  default:
1444
1041
  const parsedBody = parsedOutput.body;
1445
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1446
- response = {
1447
- ...parsedBody,
1448
- name: `${errorCode}`,
1449
- message: parsedBody.message || parsedBody.Message || errorCode,
1042
+ response = new KMSServiceException_1.KMSServiceException({
1043
+ name: parsedBody.code || parsedBody.Code || errorCode,
1450
1044
  $fault: "client",
1451
1045
  $metadata: deserializeMetadata(output),
1452
- };
1046
+ });
1047
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1453
1048
  }
1454
- const message = response.message || response.Message || errorCode;
1455
- response.message = message;
1456
- delete response.Message;
1457
- return Promise.reject(Object.assign(new Error(message), response));
1458
1049
  };
1459
1050
  const deserializeAws_json1_1DescribeKeyCommand = async (output, context) => {
1460
1051
  if (output.statusCode >= 300) {
@@ -1481,51 +1072,25 @@ const deserializeAws_json1_1DescribeKeyCommandError = async (output, context) =>
1481
1072
  switch (errorCode) {
1482
1073
  case "DependencyTimeoutException":
1483
1074
  case "com.amazonaws.kms#DependencyTimeoutException":
1484
- response = {
1485
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
1486
- name: errorCode,
1487
- $metadata: deserializeMetadata(output),
1488
- };
1489
- break;
1075
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
1490
1076
  case "InvalidArnException":
1491
1077
  case "com.amazonaws.kms#InvalidArnException":
1492
- response = {
1493
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
1494
- name: errorCode,
1495
- $metadata: deserializeMetadata(output),
1496
- };
1497
- break;
1078
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
1498
1079
  case "KMSInternalException":
1499
1080
  case "com.amazonaws.kms#KMSInternalException":
1500
- response = {
1501
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1502
- name: errorCode,
1503
- $metadata: deserializeMetadata(output),
1504
- };
1505
- break;
1081
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1506
1082
  case "NotFoundException":
1507
1083
  case "com.amazonaws.kms#NotFoundException":
1508
- response = {
1509
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
1510
- name: errorCode,
1511
- $metadata: deserializeMetadata(output),
1512
- };
1513
- break;
1084
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
1514
1085
  default:
1515
1086
  const parsedBody = parsedOutput.body;
1516
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1517
- response = {
1518
- ...parsedBody,
1519
- name: `${errorCode}`,
1520
- message: parsedBody.message || parsedBody.Message || errorCode,
1087
+ response = new KMSServiceException_1.KMSServiceException({
1088
+ name: parsedBody.code || parsedBody.Code || errorCode,
1521
1089
  $fault: "client",
1522
1090
  $metadata: deserializeMetadata(output),
1523
- };
1091
+ });
1092
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1524
1093
  }
1525
- const message = response.message || response.Message || errorCode;
1526
- response.message = message;
1527
- delete response.Message;
1528
- return Promise.reject(Object.assign(new Error(message), response));
1529
1094
  };
1530
1095
  const deserializeAws_json1_1DisableKeyCommand = async (output, context) => {
1531
1096
  if (output.statusCode >= 300) {
@@ -1549,59 +1114,28 @@ const deserializeAws_json1_1DisableKeyCommandError = async (output, context) =>
1549
1114
  switch (errorCode) {
1550
1115
  case "DependencyTimeoutException":
1551
1116
  case "com.amazonaws.kms#DependencyTimeoutException":
1552
- response = {
1553
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
1554
- name: errorCode,
1555
- $metadata: deserializeMetadata(output),
1556
- };
1557
- break;
1117
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
1558
1118
  case "InvalidArnException":
1559
1119
  case "com.amazonaws.kms#InvalidArnException":
1560
- response = {
1561
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
1562
- name: errorCode,
1563
- $metadata: deserializeMetadata(output),
1564
- };
1565
- break;
1120
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
1566
1121
  case "KMSInternalException":
1567
1122
  case "com.amazonaws.kms#KMSInternalException":
1568
- response = {
1569
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1570
- name: errorCode,
1571
- $metadata: deserializeMetadata(output),
1572
- };
1573
- break;
1123
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1574
1124
  case "KMSInvalidStateException":
1575
1125
  case "com.amazonaws.kms#KMSInvalidStateException":
1576
- response = {
1577
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
1578
- name: errorCode,
1579
- $metadata: deserializeMetadata(output),
1580
- };
1581
- break;
1126
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
1582
1127
  case "NotFoundException":
1583
1128
  case "com.amazonaws.kms#NotFoundException":
1584
- response = {
1585
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
1586
- name: errorCode,
1587
- $metadata: deserializeMetadata(output),
1588
- };
1589
- break;
1129
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
1590
1130
  default:
1591
1131
  const parsedBody = parsedOutput.body;
1592
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1593
- response = {
1594
- ...parsedBody,
1595
- name: `${errorCode}`,
1596
- message: parsedBody.message || parsedBody.Message || errorCode,
1132
+ response = new KMSServiceException_1.KMSServiceException({
1133
+ name: parsedBody.code || parsedBody.Code || errorCode,
1597
1134
  $fault: "client",
1598
1135
  $metadata: deserializeMetadata(output),
1599
- };
1136
+ });
1137
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1600
1138
  }
1601
- const message = response.message || response.Message || errorCode;
1602
- response.message = message;
1603
- delete response.Message;
1604
- return Promise.reject(Object.assign(new Error(message), response));
1605
1139
  };
1606
1140
  const deserializeAws_json1_1DisableKeyRotationCommand = async (output, context) => {
1607
1141
  if (output.statusCode >= 300) {
@@ -1625,75 +1159,34 @@ const deserializeAws_json1_1DisableKeyRotationCommandError = async (output, cont
1625
1159
  switch (errorCode) {
1626
1160
  case "DependencyTimeoutException":
1627
1161
  case "com.amazonaws.kms#DependencyTimeoutException":
1628
- response = {
1629
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
1630
- name: errorCode,
1631
- $metadata: deserializeMetadata(output),
1632
- };
1633
- break;
1162
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
1634
1163
  case "DisabledException":
1635
1164
  case "com.amazonaws.kms#DisabledException":
1636
- response = {
1637
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
1638
- name: errorCode,
1639
- $metadata: deserializeMetadata(output),
1640
- };
1641
- break;
1165
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
1642
1166
  case "InvalidArnException":
1643
1167
  case "com.amazonaws.kms#InvalidArnException":
1644
- response = {
1645
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
1646
- name: errorCode,
1647
- $metadata: deserializeMetadata(output),
1648
- };
1649
- break;
1168
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
1650
1169
  case "KMSInternalException":
1651
1170
  case "com.amazonaws.kms#KMSInternalException":
1652
- response = {
1653
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1654
- name: errorCode,
1655
- $metadata: deserializeMetadata(output),
1656
- };
1657
- break;
1171
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1658
1172
  case "KMSInvalidStateException":
1659
1173
  case "com.amazonaws.kms#KMSInvalidStateException":
1660
- response = {
1661
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
1662
- name: errorCode,
1663
- $metadata: deserializeMetadata(output),
1664
- };
1665
- break;
1174
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
1666
1175
  case "NotFoundException":
1667
1176
  case "com.amazonaws.kms#NotFoundException":
1668
- response = {
1669
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
1670
- name: errorCode,
1671
- $metadata: deserializeMetadata(output),
1672
- };
1673
- break;
1177
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
1674
1178
  case "UnsupportedOperationException":
1675
1179
  case "com.amazonaws.kms#UnsupportedOperationException":
1676
- response = {
1677
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
1678
- name: errorCode,
1679
- $metadata: deserializeMetadata(output),
1680
- };
1681
- break;
1180
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
1682
1181
  default:
1683
1182
  const parsedBody = parsedOutput.body;
1684
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1685
- response = {
1686
- ...parsedBody,
1687
- name: `${errorCode}`,
1688
- message: parsedBody.message || parsedBody.Message || errorCode,
1183
+ response = new KMSServiceException_1.KMSServiceException({
1184
+ name: parsedBody.code || parsedBody.Code || errorCode,
1689
1185
  $fault: "client",
1690
1186
  $metadata: deserializeMetadata(output),
1691
- };
1187
+ });
1188
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1692
1189
  }
1693
- const message = response.message || response.Message || errorCode;
1694
- response.message = message;
1695
- delete response.Message;
1696
- return Promise.reject(Object.assign(new Error(message), response));
1697
1190
  };
1698
1191
  const deserializeAws_json1_1DisconnectCustomKeyStoreCommand = async (output, context) => {
1699
1192
  if (output.statusCode >= 300) {
@@ -1720,43 +1213,22 @@ const deserializeAws_json1_1DisconnectCustomKeyStoreCommandError = async (output
1720
1213
  switch (errorCode) {
1721
1214
  case "CustomKeyStoreInvalidStateException":
1722
1215
  case "com.amazonaws.kms#CustomKeyStoreInvalidStateException":
1723
- response = {
1724
- ...(await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context)),
1725
- name: errorCode,
1726
- $metadata: deserializeMetadata(output),
1727
- };
1728
- break;
1216
+ throw await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context);
1729
1217
  case "CustomKeyStoreNotFoundException":
1730
1218
  case "com.amazonaws.kms#CustomKeyStoreNotFoundException":
1731
- response = {
1732
- ...(await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context)),
1733
- name: errorCode,
1734
- $metadata: deserializeMetadata(output),
1735
- };
1736
- break;
1219
+ throw await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context);
1737
1220
  case "KMSInternalException":
1738
1221
  case "com.amazonaws.kms#KMSInternalException":
1739
- response = {
1740
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1741
- name: errorCode,
1742
- $metadata: deserializeMetadata(output),
1743
- };
1744
- break;
1222
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1745
1223
  default:
1746
1224
  const parsedBody = parsedOutput.body;
1747
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1748
- response = {
1749
- ...parsedBody,
1750
- name: `${errorCode}`,
1751
- message: parsedBody.message || parsedBody.Message || errorCode,
1225
+ response = new KMSServiceException_1.KMSServiceException({
1226
+ name: parsedBody.code || parsedBody.Code || errorCode,
1752
1227
  $fault: "client",
1753
1228
  $metadata: deserializeMetadata(output),
1754
- };
1229
+ });
1230
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1755
1231
  }
1756
- const message = response.message || response.Message || errorCode;
1757
- response.message = message;
1758
- delete response.Message;
1759
- return Promise.reject(Object.assign(new Error(message), response));
1760
1232
  };
1761
1233
  const deserializeAws_json1_1EnableKeyCommand = async (output, context) => {
1762
1234
  if (output.statusCode >= 300) {
@@ -1780,67 +1252,31 @@ const deserializeAws_json1_1EnableKeyCommandError = async (output, context) => {
1780
1252
  switch (errorCode) {
1781
1253
  case "DependencyTimeoutException":
1782
1254
  case "com.amazonaws.kms#DependencyTimeoutException":
1783
- response = {
1784
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
1785
- name: errorCode,
1786
- $metadata: deserializeMetadata(output),
1787
- };
1788
- break;
1255
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
1789
1256
  case "InvalidArnException":
1790
1257
  case "com.amazonaws.kms#InvalidArnException":
1791
- response = {
1792
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
1793
- name: errorCode,
1794
- $metadata: deserializeMetadata(output),
1795
- };
1796
- break;
1258
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
1797
1259
  case "KMSInternalException":
1798
1260
  case "com.amazonaws.kms#KMSInternalException":
1799
- response = {
1800
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1801
- name: errorCode,
1802
- $metadata: deserializeMetadata(output),
1803
- };
1804
- break;
1261
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1805
1262
  case "KMSInvalidStateException":
1806
1263
  case "com.amazonaws.kms#KMSInvalidStateException":
1807
- response = {
1808
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
1809
- name: errorCode,
1810
- $metadata: deserializeMetadata(output),
1811
- };
1812
- break;
1264
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
1813
1265
  case "LimitExceededException":
1814
1266
  case "com.amazonaws.kms#LimitExceededException":
1815
- response = {
1816
- ...(await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context)),
1817
- name: errorCode,
1818
- $metadata: deserializeMetadata(output),
1819
- };
1820
- break;
1267
+ throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context);
1821
1268
  case "NotFoundException":
1822
1269
  case "com.amazonaws.kms#NotFoundException":
1823
- response = {
1824
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
1825
- name: errorCode,
1826
- $metadata: deserializeMetadata(output),
1827
- };
1828
- break;
1270
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
1829
1271
  default:
1830
1272
  const parsedBody = parsedOutput.body;
1831
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1832
- response = {
1833
- ...parsedBody,
1834
- name: `${errorCode}`,
1835
- message: parsedBody.message || parsedBody.Message || errorCode,
1273
+ response = new KMSServiceException_1.KMSServiceException({
1274
+ name: parsedBody.code || parsedBody.Code || errorCode,
1836
1275
  $fault: "client",
1837
1276
  $metadata: deserializeMetadata(output),
1838
- };
1277
+ });
1278
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1839
1279
  }
1840
- const message = response.message || response.Message || errorCode;
1841
- response.message = message;
1842
- delete response.Message;
1843
- return Promise.reject(Object.assign(new Error(message), response));
1844
1280
  };
1845
1281
  const deserializeAws_json1_1EnableKeyRotationCommand = async (output, context) => {
1846
1282
  if (output.statusCode >= 300) {
@@ -1864,75 +1300,34 @@ const deserializeAws_json1_1EnableKeyRotationCommandError = async (output, conte
1864
1300
  switch (errorCode) {
1865
1301
  case "DependencyTimeoutException":
1866
1302
  case "com.amazonaws.kms#DependencyTimeoutException":
1867
- response = {
1868
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
1869
- name: errorCode,
1870
- $metadata: deserializeMetadata(output),
1871
- };
1872
- break;
1303
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
1873
1304
  case "DisabledException":
1874
1305
  case "com.amazonaws.kms#DisabledException":
1875
- response = {
1876
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
1877
- name: errorCode,
1878
- $metadata: deserializeMetadata(output),
1879
- };
1880
- break;
1306
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
1881
1307
  case "InvalidArnException":
1882
1308
  case "com.amazonaws.kms#InvalidArnException":
1883
- response = {
1884
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
1885
- name: errorCode,
1886
- $metadata: deserializeMetadata(output),
1887
- };
1888
- break;
1309
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
1889
1310
  case "KMSInternalException":
1890
1311
  case "com.amazonaws.kms#KMSInternalException":
1891
- response = {
1892
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
1893
- name: errorCode,
1894
- $metadata: deserializeMetadata(output),
1895
- };
1896
- break;
1312
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
1897
1313
  case "KMSInvalidStateException":
1898
1314
  case "com.amazonaws.kms#KMSInvalidStateException":
1899
- response = {
1900
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
1901
- name: errorCode,
1902
- $metadata: deserializeMetadata(output),
1903
- };
1904
- break;
1315
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
1905
1316
  case "NotFoundException":
1906
1317
  case "com.amazonaws.kms#NotFoundException":
1907
- response = {
1908
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
1909
- name: errorCode,
1910
- $metadata: deserializeMetadata(output),
1911
- };
1912
- break;
1318
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
1913
1319
  case "UnsupportedOperationException":
1914
1320
  case "com.amazonaws.kms#UnsupportedOperationException":
1915
- response = {
1916
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
1917
- name: errorCode,
1918
- $metadata: deserializeMetadata(output),
1919
- };
1920
- break;
1321
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
1921
1322
  default:
1922
1323
  const parsedBody = parsedOutput.body;
1923
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1924
- response = {
1925
- ...parsedBody,
1926
- name: `${errorCode}`,
1927
- message: parsedBody.message || parsedBody.Message || errorCode,
1324
+ response = new KMSServiceException_1.KMSServiceException({
1325
+ name: parsedBody.code || parsedBody.Code || errorCode,
1928
1326
  $fault: "client",
1929
1327
  $metadata: deserializeMetadata(output),
1930
- };
1328
+ });
1329
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
1931
1330
  }
1932
- const message = response.message || response.Message || errorCode;
1933
- response.message = message;
1934
- delete response.Message;
1935
- return Promise.reject(Object.assign(new Error(message), response));
1936
1331
  };
1937
1332
  const deserializeAws_json1_1EncryptCommand = async (output, context) => {
1938
1333
  if (output.statusCode >= 300) {
@@ -1959,83 +1354,37 @@ const deserializeAws_json1_1EncryptCommandError = async (output, context) => {
1959
1354
  switch (errorCode) {
1960
1355
  case "DependencyTimeoutException":
1961
1356
  case "com.amazonaws.kms#DependencyTimeoutException":
1962
- response = {
1963
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
1964
- name: errorCode,
1965
- $metadata: deserializeMetadata(output),
1966
- };
1967
- break;
1357
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
1968
1358
  case "DisabledException":
1969
1359
  case "com.amazonaws.kms#DisabledException":
1970
- response = {
1971
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
1972
- name: errorCode,
1973
- $metadata: deserializeMetadata(output),
1974
- };
1975
- break;
1360
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
1976
1361
  case "InvalidGrantTokenException":
1977
1362
  case "com.amazonaws.kms#InvalidGrantTokenException":
1978
- response = {
1979
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
1980
- name: errorCode,
1981
- $metadata: deserializeMetadata(output),
1982
- };
1983
- break;
1363
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
1984
1364
  case "InvalidKeyUsageException":
1985
1365
  case "com.amazonaws.kms#InvalidKeyUsageException":
1986
- response = {
1987
- ...(await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context)),
1988
- name: errorCode,
1989
- $metadata: deserializeMetadata(output),
1990
- };
1991
- break;
1366
+ throw await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context);
1992
1367
  case "KeyUnavailableException":
1993
1368
  case "com.amazonaws.kms#KeyUnavailableException":
1994
- response = {
1995
- ...(await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context)),
1996
- name: errorCode,
1997
- $metadata: deserializeMetadata(output),
1998
- };
1999
- break;
1369
+ throw await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context);
2000
1370
  case "KMSInternalException":
2001
1371
  case "com.amazonaws.kms#KMSInternalException":
2002
- response = {
2003
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2004
- name: errorCode,
2005
- $metadata: deserializeMetadata(output),
2006
- };
2007
- break;
1372
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2008
1373
  case "KMSInvalidStateException":
2009
1374
  case "com.amazonaws.kms#KMSInvalidStateException":
2010
- response = {
2011
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
2012
- name: errorCode,
2013
- $metadata: deserializeMetadata(output),
2014
- };
2015
- break;
1375
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
2016
1376
  case "NotFoundException":
2017
1377
  case "com.amazonaws.kms#NotFoundException":
2018
- response = {
2019
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
2020
- name: errorCode,
2021
- $metadata: deserializeMetadata(output),
2022
- };
2023
- break;
1378
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
2024
1379
  default:
2025
1380
  const parsedBody = parsedOutput.body;
2026
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
2027
- response = {
2028
- ...parsedBody,
2029
- name: `${errorCode}`,
2030
- message: parsedBody.message || parsedBody.Message || errorCode,
1381
+ response = new KMSServiceException_1.KMSServiceException({
1382
+ name: parsedBody.code || parsedBody.Code || errorCode,
2031
1383
  $fault: "client",
2032
1384
  $metadata: deserializeMetadata(output),
2033
- };
1385
+ });
1386
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
2034
1387
  }
2035
- const message = response.message || response.Message || errorCode;
2036
- response.message = message;
2037
- delete response.Message;
2038
- return Promise.reject(Object.assign(new Error(message), response));
2039
1388
  };
2040
1389
  const deserializeAws_json1_1GenerateDataKeyCommand = async (output, context) => {
2041
1390
  if (output.statusCode >= 300) {
@@ -2062,83 +1411,37 @@ const deserializeAws_json1_1GenerateDataKeyCommandError = async (output, context
2062
1411
  switch (errorCode) {
2063
1412
  case "DependencyTimeoutException":
2064
1413
  case "com.amazonaws.kms#DependencyTimeoutException":
2065
- response = {
2066
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
2067
- name: errorCode,
2068
- $metadata: deserializeMetadata(output),
2069
- };
2070
- break;
1414
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
2071
1415
  case "DisabledException":
2072
1416
  case "com.amazonaws.kms#DisabledException":
2073
- response = {
2074
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
2075
- name: errorCode,
2076
- $metadata: deserializeMetadata(output),
2077
- };
2078
- break;
1417
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
2079
1418
  case "InvalidGrantTokenException":
2080
1419
  case "com.amazonaws.kms#InvalidGrantTokenException":
2081
- response = {
2082
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
2083
- name: errorCode,
2084
- $metadata: deserializeMetadata(output),
2085
- };
2086
- break;
1420
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
2087
1421
  case "InvalidKeyUsageException":
2088
1422
  case "com.amazonaws.kms#InvalidKeyUsageException":
2089
- response = {
2090
- ...(await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context)),
2091
- name: errorCode,
2092
- $metadata: deserializeMetadata(output),
2093
- };
2094
- break;
1423
+ throw await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context);
2095
1424
  case "KeyUnavailableException":
2096
1425
  case "com.amazonaws.kms#KeyUnavailableException":
2097
- response = {
2098
- ...(await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context)),
2099
- name: errorCode,
2100
- $metadata: deserializeMetadata(output),
2101
- };
2102
- break;
1426
+ throw await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context);
2103
1427
  case "KMSInternalException":
2104
1428
  case "com.amazonaws.kms#KMSInternalException":
2105
- response = {
2106
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2107
- name: errorCode,
2108
- $metadata: deserializeMetadata(output),
2109
- };
2110
- break;
1429
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2111
1430
  case "KMSInvalidStateException":
2112
1431
  case "com.amazonaws.kms#KMSInvalidStateException":
2113
- response = {
2114
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
2115
- name: errorCode,
2116
- $metadata: deserializeMetadata(output),
2117
- };
2118
- break;
1432
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
2119
1433
  case "NotFoundException":
2120
1434
  case "com.amazonaws.kms#NotFoundException":
2121
- response = {
2122
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
2123
- name: errorCode,
2124
- $metadata: deserializeMetadata(output),
2125
- };
2126
- break;
1435
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
2127
1436
  default:
2128
1437
  const parsedBody = parsedOutput.body;
2129
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
2130
- response = {
2131
- ...parsedBody,
2132
- name: `${errorCode}`,
2133
- message: parsedBody.message || parsedBody.Message || errorCode,
1438
+ response = new KMSServiceException_1.KMSServiceException({
1439
+ name: parsedBody.code || parsedBody.Code || errorCode,
2134
1440
  $fault: "client",
2135
1441
  $metadata: deserializeMetadata(output),
2136
- };
1442
+ });
1443
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
2137
1444
  }
2138
- const message = response.message || response.Message || errorCode;
2139
- response.message = message;
2140
- delete response.Message;
2141
- return Promise.reject(Object.assign(new Error(message), response));
2142
1445
  };
2143
1446
  const deserializeAws_json1_1GenerateDataKeyPairCommand = async (output, context) => {
2144
1447
  if (output.statusCode >= 300) {
@@ -2165,91 +1468,40 @@ const deserializeAws_json1_1GenerateDataKeyPairCommandError = async (output, con
2165
1468
  switch (errorCode) {
2166
1469
  case "DependencyTimeoutException":
2167
1470
  case "com.amazonaws.kms#DependencyTimeoutException":
2168
- response = {
2169
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
2170
- name: errorCode,
2171
- $metadata: deserializeMetadata(output),
2172
- };
2173
- break;
1471
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
2174
1472
  case "DisabledException":
2175
1473
  case "com.amazonaws.kms#DisabledException":
2176
- response = {
2177
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
2178
- name: errorCode,
2179
- $metadata: deserializeMetadata(output),
2180
- };
2181
- break;
1474
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
2182
1475
  case "InvalidGrantTokenException":
2183
1476
  case "com.amazonaws.kms#InvalidGrantTokenException":
2184
- response = {
2185
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
2186
- name: errorCode,
2187
- $metadata: deserializeMetadata(output),
2188
- };
2189
- break;
1477
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
2190
1478
  case "InvalidKeyUsageException":
2191
1479
  case "com.amazonaws.kms#InvalidKeyUsageException":
2192
- response = {
2193
- ...(await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context)),
2194
- name: errorCode,
2195
- $metadata: deserializeMetadata(output),
2196
- };
2197
- break;
1480
+ throw await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context);
2198
1481
  case "KeyUnavailableException":
2199
1482
  case "com.amazonaws.kms#KeyUnavailableException":
2200
- response = {
2201
- ...(await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context)),
2202
- name: errorCode,
2203
- $metadata: deserializeMetadata(output),
2204
- };
2205
- break;
1483
+ throw await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context);
2206
1484
  case "KMSInternalException":
2207
1485
  case "com.amazonaws.kms#KMSInternalException":
2208
- response = {
2209
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2210
- name: errorCode,
2211
- $metadata: deserializeMetadata(output),
2212
- };
2213
- break;
1486
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2214
1487
  case "KMSInvalidStateException":
2215
1488
  case "com.amazonaws.kms#KMSInvalidStateException":
2216
- response = {
2217
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
2218
- name: errorCode,
2219
- $metadata: deserializeMetadata(output),
2220
- };
2221
- break;
1489
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
2222
1490
  case "NotFoundException":
2223
1491
  case "com.amazonaws.kms#NotFoundException":
2224
- response = {
2225
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
2226
- name: errorCode,
2227
- $metadata: deserializeMetadata(output),
2228
- };
2229
- break;
1492
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
2230
1493
  case "UnsupportedOperationException":
2231
1494
  case "com.amazonaws.kms#UnsupportedOperationException":
2232
- response = {
2233
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
2234
- name: errorCode,
2235
- $metadata: deserializeMetadata(output),
2236
- };
2237
- break;
1495
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
2238
1496
  default:
2239
1497
  const parsedBody = parsedOutput.body;
2240
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
2241
- response = {
2242
- ...parsedBody,
2243
- name: `${errorCode}`,
2244
- message: parsedBody.message || parsedBody.Message || errorCode,
1498
+ response = new KMSServiceException_1.KMSServiceException({
1499
+ name: parsedBody.code || parsedBody.Code || errorCode,
2245
1500
  $fault: "client",
2246
1501
  $metadata: deserializeMetadata(output),
2247
- };
1502
+ });
1503
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
2248
1504
  }
2249
- const message = response.message || response.Message || errorCode;
2250
- response.message = message;
2251
- delete response.Message;
2252
- return Promise.reject(Object.assign(new Error(message), response));
2253
1505
  };
2254
1506
  const deserializeAws_json1_1GenerateDataKeyPairWithoutPlaintextCommand = async (output, context) => {
2255
1507
  if (output.statusCode >= 300) {
@@ -2276,91 +1528,40 @@ const deserializeAws_json1_1GenerateDataKeyPairWithoutPlaintextCommandError = as
2276
1528
  switch (errorCode) {
2277
1529
  case "DependencyTimeoutException":
2278
1530
  case "com.amazonaws.kms#DependencyTimeoutException":
2279
- response = {
2280
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
2281
- name: errorCode,
2282
- $metadata: deserializeMetadata(output),
2283
- };
2284
- break;
1531
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
2285
1532
  case "DisabledException":
2286
1533
  case "com.amazonaws.kms#DisabledException":
2287
- response = {
2288
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
2289
- name: errorCode,
2290
- $metadata: deserializeMetadata(output),
2291
- };
2292
- break;
1534
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
2293
1535
  case "InvalidGrantTokenException":
2294
1536
  case "com.amazonaws.kms#InvalidGrantTokenException":
2295
- response = {
2296
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
2297
- name: errorCode,
2298
- $metadata: deserializeMetadata(output),
2299
- };
2300
- break;
1537
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
2301
1538
  case "InvalidKeyUsageException":
2302
1539
  case "com.amazonaws.kms#InvalidKeyUsageException":
2303
- response = {
2304
- ...(await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context)),
2305
- name: errorCode,
2306
- $metadata: deserializeMetadata(output),
2307
- };
2308
- break;
1540
+ throw await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context);
2309
1541
  case "KeyUnavailableException":
2310
1542
  case "com.amazonaws.kms#KeyUnavailableException":
2311
- response = {
2312
- ...(await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context)),
2313
- name: errorCode,
2314
- $metadata: deserializeMetadata(output),
2315
- };
2316
- break;
1543
+ throw await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context);
2317
1544
  case "KMSInternalException":
2318
1545
  case "com.amazonaws.kms#KMSInternalException":
2319
- response = {
2320
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2321
- name: errorCode,
2322
- $metadata: deserializeMetadata(output),
2323
- };
2324
- break;
1546
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2325
1547
  case "KMSInvalidStateException":
2326
1548
  case "com.amazonaws.kms#KMSInvalidStateException":
2327
- response = {
2328
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
2329
- name: errorCode,
2330
- $metadata: deserializeMetadata(output),
2331
- };
2332
- break;
1549
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
2333
1550
  case "NotFoundException":
2334
1551
  case "com.amazonaws.kms#NotFoundException":
2335
- response = {
2336
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
2337
- name: errorCode,
2338
- $metadata: deserializeMetadata(output),
2339
- };
2340
- break;
1552
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
2341
1553
  case "UnsupportedOperationException":
2342
1554
  case "com.amazonaws.kms#UnsupportedOperationException":
2343
- response = {
2344
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
2345
- name: errorCode,
2346
- $metadata: deserializeMetadata(output),
2347
- };
2348
- break;
1555
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
2349
1556
  default:
2350
1557
  const parsedBody = parsedOutput.body;
2351
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
2352
- response = {
2353
- ...parsedBody,
2354
- name: `${errorCode}`,
2355
- message: parsedBody.message || parsedBody.Message || errorCode,
1558
+ response = new KMSServiceException_1.KMSServiceException({
1559
+ name: parsedBody.code || parsedBody.Code || errorCode,
2356
1560
  $fault: "client",
2357
1561
  $metadata: deserializeMetadata(output),
2358
- };
1562
+ });
1563
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
2359
1564
  }
2360
- const message = response.message || response.Message || errorCode;
2361
- response.message = message;
2362
- delete response.Message;
2363
- return Promise.reject(Object.assign(new Error(message), response));
2364
1565
  };
2365
1566
  const deserializeAws_json1_1GenerateDataKeyWithoutPlaintextCommand = async (output, context) => {
2366
1567
  if (output.statusCode >= 300) {
@@ -2387,83 +1588,37 @@ const deserializeAws_json1_1GenerateDataKeyWithoutPlaintextCommandError = async
2387
1588
  switch (errorCode) {
2388
1589
  case "DependencyTimeoutException":
2389
1590
  case "com.amazonaws.kms#DependencyTimeoutException":
2390
- response = {
2391
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
2392
- name: errorCode,
2393
- $metadata: deserializeMetadata(output),
2394
- };
2395
- break;
1591
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
2396
1592
  case "DisabledException":
2397
1593
  case "com.amazonaws.kms#DisabledException":
2398
- response = {
2399
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
2400
- name: errorCode,
2401
- $metadata: deserializeMetadata(output),
2402
- };
2403
- break;
1594
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
2404
1595
  case "InvalidGrantTokenException":
2405
1596
  case "com.amazonaws.kms#InvalidGrantTokenException":
2406
- response = {
2407
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
2408
- name: errorCode,
2409
- $metadata: deserializeMetadata(output),
2410
- };
2411
- break;
1597
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
2412
1598
  case "InvalidKeyUsageException":
2413
1599
  case "com.amazonaws.kms#InvalidKeyUsageException":
2414
- response = {
2415
- ...(await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context)),
2416
- name: errorCode,
2417
- $metadata: deserializeMetadata(output),
2418
- };
2419
- break;
1600
+ throw await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context);
2420
1601
  case "KeyUnavailableException":
2421
1602
  case "com.amazonaws.kms#KeyUnavailableException":
2422
- response = {
2423
- ...(await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context)),
2424
- name: errorCode,
2425
- $metadata: deserializeMetadata(output),
2426
- };
2427
- break;
1603
+ throw await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context);
2428
1604
  case "KMSInternalException":
2429
1605
  case "com.amazonaws.kms#KMSInternalException":
2430
- response = {
2431
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2432
- name: errorCode,
2433
- $metadata: deserializeMetadata(output),
2434
- };
2435
- break;
1606
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2436
1607
  case "KMSInvalidStateException":
2437
1608
  case "com.amazonaws.kms#KMSInvalidStateException":
2438
- response = {
2439
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
2440
- name: errorCode,
2441
- $metadata: deserializeMetadata(output),
2442
- };
2443
- break;
1609
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
2444
1610
  case "NotFoundException":
2445
1611
  case "com.amazonaws.kms#NotFoundException":
2446
- response = {
2447
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
2448
- name: errorCode,
2449
- $metadata: deserializeMetadata(output),
2450
- };
2451
- break;
1612
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
2452
1613
  default:
2453
1614
  const parsedBody = parsedOutput.body;
2454
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
2455
- response = {
2456
- ...parsedBody,
2457
- name: `${errorCode}`,
2458
- message: parsedBody.message || parsedBody.Message || errorCode,
1615
+ response = new KMSServiceException_1.KMSServiceException({
1616
+ name: parsedBody.code || parsedBody.Code || errorCode,
2459
1617
  $fault: "client",
2460
1618
  $metadata: deserializeMetadata(output),
2461
- };
1619
+ });
1620
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
2462
1621
  }
2463
- const message = response.message || response.Message || errorCode;
2464
- response.message = message;
2465
- delete response.Message;
2466
- return Promise.reject(Object.assign(new Error(message), response));
2467
1622
  };
2468
1623
  const deserializeAws_json1_1GenerateRandomCommand = async (output, context) => {
2469
1624
  if (output.statusCode >= 300) {
@@ -2490,51 +1645,25 @@ const deserializeAws_json1_1GenerateRandomCommandError = async (output, context)
2490
1645
  switch (errorCode) {
2491
1646
  case "CustomKeyStoreInvalidStateException":
2492
1647
  case "com.amazonaws.kms#CustomKeyStoreInvalidStateException":
2493
- response = {
2494
- ...(await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context)),
2495
- name: errorCode,
2496
- $metadata: deserializeMetadata(output),
2497
- };
2498
- break;
1648
+ throw await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context);
2499
1649
  case "CustomKeyStoreNotFoundException":
2500
1650
  case "com.amazonaws.kms#CustomKeyStoreNotFoundException":
2501
- response = {
2502
- ...(await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context)),
2503
- name: errorCode,
2504
- $metadata: deserializeMetadata(output),
2505
- };
2506
- break;
1651
+ throw await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context);
2507
1652
  case "DependencyTimeoutException":
2508
1653
  case "com.amazonaws.kms#DependencyTimeoutException":
2509
- response = {
2510
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
2511
- name: errorCode,
2512
- $metadata: deserializeMetadata(output),
2513
- };
2514
- break;
1654
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
2515
1655
  case "KMSInternalException":
2516
1656
  case "com.amazonaws.kms#KMSInternalException":
2517
- response = {
2518
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2519
- name: errorCode,
2520
- $metadata: deserializeMetadata(output),
2521
- };
2522
- break;
1657
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2523
1658
  default:
2524
1659
  const parsedBody = parsedOutput.body;
2525
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
2526
- response = {
2527
- ...parsedBody,
2528
- name: `${errorCode}`,
2529
- message: parsedBody.message || parsedBody.Message || errorCode,
1660
+ response = new KMSServiceException_1.KMSServiceException({
1661
+ name: parsedBody.code || parsedBody.Code || errorCode,
2530
1662
  $fault: "client",
2531
1663
  $metadata: deserializeMetadata(output),
2532
- };
1664
+ });
1665
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
2533
1666
  }
2534
- const message = response.message || response.Message || errorCode;
2535
- response.message = message;
2536
- delete response.Message;
2537
- return Promise.reject(Object.assign(new Error(message), response));
2538
1667
  };
2539
1668
  const deserializeAws_json1_1GetKeyPolicyCommand = async (output, context) => {
2540
1669
  if (output.statusCode >= 300) {
@@ -2561,59 +1690,28 @@ const deserializeAws_json1_1GetKeyPolicyCommandError = async (output, context) =
2561
1690
  switch (errorCode) {
2562
1691
  case "DependencyTimeoutException":
2563
1692
  case "com.amazonaws.kms#DependencyTimeoutException":
2564
- response = {
2565
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
2566
- name: errorCode,
2567
- $metadata: deserializeMetadata(output),
2568
- };
2569
- break;
1693
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
2570
1694
  case "InvalidArnException":
2571
1695
  case "com.amazonaws.kms#InvalidArnException":
2572
- response = {
2573
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
2574
- name: errorCode,
2575
- $metadata: deserializeMetadata(output),
2576
- };
2577
- break;
1696
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
2578
1697
  case "KMSInternalException":
2579
1698
  case "com.amazonaws.kms#KMSInternalException":
2580
- response = {
2581
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2582
- name: errorCode,
2583
- $metadata: deserializeMetadata(output),
2584
- };
2585
- break;
1699
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2586
1700
  case "KMSInvalidStateException":
2587
1701
  case "com.amazonaws.kms#KMSInvalidStateException":
2588
- response = {
2589
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
2590
- name: errorCode,
2591
- $metadata: deserializeMetadata(output),
2592
- };
2593
- break;
1702
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
2594
1703
  case "NotFoundException":
2595
1704
  case "com.amazonaws.kms#NotFoundException":
2596
- response = {
2597
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
2598
- name: errorCode,
2599
- $metadata: deserializeMetadata(output),
2600
- };
2601
- break;
1705
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
2602
1706
  default:
2603
1707
  const parsedBody = parsedOutput.body;
2604
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
2605
- response = {
2606
- ...parsedBody,
2607
- name: `${errorCode}`,
2608
- message: parsedBody.message || parsedBody.Message || errorCode,
1708
+ response = new KMSServiceException_1.KMSServiceException({
1709
+ name: parsedBody.code || parsedBody.Code || errorCode,
2609
1710
  $fault: "client",
2610
1711
  $metadata: deserializeMetadata(output),
2611
- };
1712
+ });
1713
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
2612
1714
  }
2613
- const message = response.message || response.Message || errorCode;
2614
- response.message = message;
2615
- delete response.Message;
2616
- return Promise.reject(Object.assign(new Error(message), response));
2617
1715
  };
2618
1716
  const deserializeAws_json1_1GetKeyRotationStatusCommand = async (output, context) => {
2619
1717
  if (output.statusCode >= 300) {
@@ -2640,67 +1738,31 @@ const deserializeAws_json1_1GetKeyRotationStatusCommandError = async (output, co
2640
1738
  switch (errorCode) {
2641
1739
  case "DependencyTimeoutException":
2642
1740
  case "com.amazonaws.kms#DependencyTimeoutException":
2643
- response = {
2644
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
2645
- name: errorCode,
2646
- $metadata: deserializeMetadata(output),
2647
- };
2648
- break;
1741
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
2649
1742
  case "InvalidArnException":
2650
1743
  case "com.amazonaws.kms#InvalidArnException":
2651
- response = {
2652
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
2653
- name: errorCode,
2654
- $metadata: deserializeMetadata(output),
2655
- };
2656
- break;
1744
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
2657
1745
  case "KMSInternalException":
2658
1746
  case "com.amazonaws.kms#KMSInternalException":
2659
- response = {
2660
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2661
- name: errorCode,
2662
- $metadata: deserializeMetadata(output),
2663
- };
2664
- break;
1747
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2665
1748
  case "KMSInvalidStateException":
2666
1749
  case "com.amazonaws.kms#KMSInvalidStateException":
2667
- response = {
2668
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
2669
- name: errorCode,
2670
- $metadata: deserializeMetadata(output),
2671
- };
2672
- break;
1750
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
2673
1751
  case "NotFoundException":
2674
1752
  case "com.amazonaws.kms#NotFoundException":
2675
- response = {
2676
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
2677
- name: errorCode,
2678
- $metadata: deserializeMetadata(output),
2679
- };
2680
- break;
1753
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
2681
1754
  case "UnsupportedOperationException":
2682
1755
  case "com.amazonaws.kms#UnsupportedOperationException":
2683
- response = {
2684
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
2685
- name: errorCode,
2686
- $metadata: deserializeMetadata(output),
2687
- };
2688
- break;
1756
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
2689
1757
  default:
2690
1758
  const parsedBody = parsedOutput.body;
2691
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
2692
- response = {
2693
- ...parsedBody,
2694
- name: `${errorCode}`,
2695
- message: parsedBody.message || parsedBody.Message || errorCode,
1759
+ response = new KMSServiceException_1.KMSServiceException({
1760
+ name: parsedBody.code || parsedBody.Code || errorCode,
2696
1761
  $fault: "client",
2697
1762
  $metadata: deserializeMetadata(output),
2698
- };
1763
+ });
1764
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
2699
1765
  }
2700
- const message = response.message || response.Message || errorCode;
2701
- response.message = message;
2702
- delete response.Message;
2703
- return Promise.reject(Object.assign(new Error(message), response));
2704
1766
  };
2705
1767
  const deserializeAws_json1_1GetParametersForImportCommand = async (output, context) => {
2706
1768
  if (output.statusCode >= 300) {
@@ -2727,67 +1789,31 @@ const deserializeAws_json1_1GetParametersForImportCommandError = async (output,
2727
1789
  switch (errorCode) {
2728
1790
  case "DependencyTimeoutException":
2729
1791
  case "com.amazonaws.kms#DependencyTimeoutException":
2730
- response = {
2731
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
2732
- name: errorCode,
2733
- $metadata: deserializeMetadata(output),
2734
- };
2735
- break;
1792
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
2736
1793
  case "InvalidArnException":
2737
1794
  case "com.amazonaws.kms#InvalidArnException":
2738
- response = {
2739
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
2740
- name: errorCode,
2741
- $metadata: deserializeMetadata(output),
2742
- };
2743
- break;
1795
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
2744
1796
  case "KMSInternalException":
2745
1797
  case "com.amazonaws.kms#KMSInternalException":
2746
- response = {
2747
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2748
- name: errorCode,
2749
- $metadata: deserializeMetadata(output),
2750
- };
2751
- break;
1798
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2752
1799
  case "KMSInvalidStateException":
2753
1800
  case "com.amazonaws.kms#KMSInvalidStateException":
2754
- response = {
2755
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
2756
- name: errorCode,
2757
- $metadata: deserializeMetadata(output),
2758
- };
2759
- break;
1801
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
2760
1802
  case "NotFoundException":
2761
1803
  case "com.amazonaws.kms#NotFoundException":
2762
- response = {
2763
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
2764
- name: errorCode,
2765
- $metadata: deserializeMetadata(output),
2766
- };
2767
- break;
1804
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
2768
1805
  case "UnsupportedOperationException":
2769
1806
  case "com.amazonaws.kms#UnsupportedOperationException":
2770
- response = {
2771
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
2772
- name: errorCode,
2773
- $metadata: deserializeMetadata(output),
2774
- };
2775
- break;
1807
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
2776
1808
  default:
2777
1809
  const parsedBody = parsedOutput.body;
2778
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
2779
- response = {
2780
- ...parsedBody,
2781
- name: `${errorCode}`,
2782
- message: parsedBody.message || parsedBody.Message || errorCode,
1810
+ response = new KMSServiceException_1.KMSServiceException({
1811
+ name: parsedBody.code || parsedBody.Code || errorCode,
2783
1812
  $fault: "client",
2784
1813
  $metadata: deserializeMetadata(output),
2785
- };
1814
+ });
1815
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
2786
1816
  }
2787
- const message = response.message || response.Message || errorCode;
2788
- response.message = message;
2789
- delete response.Message;
2790
- return Promise.reject(Object.assign(new Error(message), response));
2791
1817
  };
2792
1818
  const deserializeAws_json1_1GetPublicKeyCommand = async (output, context) => {
2793
1819
  if (output.statusCode >= 300) {
@@ -2814,99 +1840,43 @@ const deserializeAws_json1_1GetPublicKeyCommandError = async (output, context) =
2814
1840
  switch (errorCode) {
2815
1841
  case "DependencyTimeoutException":
2816
1842
  case "com.amazonaws.kms#DependencyTimeoutException":
2817
- response = {
2818
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
2819
- name: errorCode,
2820
- $metadata: deserializeMetadata(output),
2821
- };
2822
- break;
1843
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
2823
1844
  case "DisabledException":
2824
1845
  case "com.amazonaws.kms#DisabledException":
2825
- response = {
2826
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
2827
- name: errorCode,
2828
- $metadata: deserializeMetadata(output),
2829
- };
2830
- break;
1846
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
2831
1847
  case "InvalidArnException":
2832
1848
  case "com.amazonaws.kms#InvalidArnException":
2833
- response = {
2834
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
2835
- name: errorCode,
2836
- $metadata: deserializeMetadata(output),
2837
- };
2838
- break;
1849
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
2839
1850
  case "InvalidGrantTokenException":
2840
1851
  case "com.amazonaws.kms#InvalidGrantTokenException":
2841
- response = {
2842
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
2843
- name: errorCode,
2844
- $metadata: deserializeMetadata(output),
2845
- };
2846
- break;
1852
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
2847
1853
  case "InvalidKeyUsageException":
2848
1854
  case "com.amazonaws.kms#InvalidKeyUsageException":
2849
- response = {
2850
- ...(await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context)),
2851
- name: errorCode,
2852
- $metadata: deserializeMetadata(output),
2853
- };
2854
- break;
1855
+ throw await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context);
2855
1856
  case "KeyUnavailableException":
2856
1857
  case "com.amazonaws.kms#KeyUnavailableException":
2857
- response = {
2858
- ...(await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context)),
2859
- name: errorCode,
2860
- $metadata: deserializeMetadata(output),
2861
- };
2862
- break;
1858
+ throw await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context);
2863
1859
  case "KMSInternalException":
2864
1860
  case "com.amazonaws.kms#KMSInternalException":
2865
- response = {
2866
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2867
- name: errorCode,
2868
- $metadata: deserializeMetadata(output),
2869
- };
2870
- break;
1861
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2871
1862
  case "KMSInvalidStateException":
2872
1863
  case "com.amazonaws.kms#KMSInvalidStateException":
2873
- response = {
2874
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
2875
- name: errorCode,
2876
- $metadata: deserializeMetadata(output),
2877
- };
2878
- break;
1864
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
2879
1865
  case "NotFoundException":
2880
1866
  case "com.amazonaws.kms#NotFoundException":
2881
- response = {
2882
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
2883
- name: errorCode,
2884
- $metadata: deserializeMetadata(output),
2885
- };
2886
- break;
1867
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
2887
1868
  case "UnsupportedOperationException":
2888
1869
  case "com.amazonaws.kms#UnsupportedOperationException":
2889
- response = {
2890
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
2891
- name: errorCode,
2892
- $metadata: deserializeMetadata(output),
2893
- };
2894
- break;
1870
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
2895
1871
  default:
2896
1872
  const parsedBody = parsedOutput.body;
2897
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
2898
- response = {
2899
- ...parsedBody,
2900
- name: `${errorCode}`,
2901
- message: parsedBody.message || parsedBody.Message || errorCode,
1873
+ response = new KMSServiceException_1.KMSServiceException({
1874
+ name: parsedBody.code || parsedBody.Code || errorCode,
2902
1875
  $fault: "client",
2903
1876
  $metadata: deserializeMetadata(output),
2904
- };
1877
+ });
1878
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
2905
1879
  }
2906
- const message = response.message || response.Message || errorCode;
2907
- response.message = message;
2908
- delete response.Message;
2909
- return Promise.reject(Object.assign(new Error(message), response));
2910
1880
  };
2911
1881
  const deserializeAws_json1_1ImportKeyMaterialCommand = async (output, context) => {
2912
1882
  if (output.statusCode >= 300) {
@@ -2933,99 +1903,43 @@ const deserializeAws_json1_1ImportKeyMaterialCommandError = async (output, conte
2933
1903
  switch (errorCode) {
2934
1904
  case "DependencyTimeoutException":
2935
1905
  case "com.amazonaws.kms#DependencyTimeoutException":
2936
- response = {
2937
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
2938
- name: errorCode,
2939
- $metadata: deserializeMetadata(output),
2940
- };
2941
- break;
1906
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
2942
1907
  case "ExpiredImportTokenException":
2943
1908
  case "com.amazonaws.kms#ExpiredImportTokenException":
2944
- response = {
2945
- ...(await deserializeAws_json1_1ExpiredImportTokenExceptionResponse(parsedOutput, context)),
2946
- name: errorCode,
2947
- $metadata: deserializeMetadata(output),
2948
- };
2949
- break;
1909
+ throw await deserializeAws_json1_1ExpiredImportTokenExceptionResponse(parsedOutput, context);
2950
1910
  case "IncorrectKeyMaterialException":
2951
1911
  case "com.amazonaws.kms#IncorrectKeyMaterialException":
2952
- response = {
2953
- ...(await deserializeAws_json1_1IncorrectKeyMaterialExceptionResponse(parsedOutput, context)),
2954
- name: errorCode,
2955
- $metadata: deserializeMetadata(output),
2956
- };
2957
- break;
1912
+ throw await deserializeAws_json1_1IncorrectKeyMaterialExceptionResponse(parsedOutput, context);
2958
1913
  case "InvalidArnException":
2959
1914
  case "com.amazonaws.kms#InvalidArnException":
2960
- response = {
2961
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
2962
- name: errorCode,
2963
- $metadata: deserializeMetadata(output),
2964
- };
2965
- break;
1915
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
2966
1916
  case "InvalidCiphertextException":
2967
1917
  case "com.amazonaws.kms#InvalidCiphertextException":
2968
- response = {
2969
- ...(await deserializeAws_json1_1InvalidCiphertextExceptionResponse(parsedOutput, context)),
2970
- name: errorCode,
2971
- $metadata: deserializeMetadata(output),
2972
- };
2973
- break;
1918
+ throw await deserializeAws_json1_1InvalidCiphertextExceptionResponse(parsedOutput, context);
2974
1919
  case "InvalidImportTokenException":
2975
1920
  case "com.amazonaws.kms#InvalidImportTokenException":
2976
- response = {
2977
- ...(await deserializeAws_json1_1InvalidImportTokenExceptionResponse(parsedOutput, context)),
2978
- name: errorCode,
2979
- $metadata: deserializeMetadata(output),
2980
- };
2981
- break;
1921
+ throw await deserializeAws_json1_1InvalidImportTokenExceptionResponse(parsedOutput, context);
2982
1922
  case "KMSInternalException":
2983
1923
  case "com.amazonaws.kms#KMSInternalException":
2984
- response = {
2985
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
2986
- name: errorCode,
2987
- $metadata: deserializeMetadata(output),
2988
- };
2989
- break;
1924
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
2990
1925
  case "KMSInvalidStateException":
2991
1926
  case "com.amazonaws.kms#KMSInvalidStateException":
2992
- response = {
2993
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
2994
- name: errorCode,
2995
- $metadata: deserializeMetadata(output),
2996
- };
2997
- break;
1927
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
2998
1928
  case "NotFoundException":
2999
1929
  case "com.amazonaws.kms#NotFoundException":
3000
- response = {
3001
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3002
- name: errorCode,
3003
- $metadata: deserializeMetadata(output),
3004
- };
3005
- break;
1930
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3006
1931
  case "UnsupportedOperationException":
3007
1932
  case "com.amazonaws.kms#UnsupportedOperationException":
3008
- response = {
3009
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
3010
- name: errorCode,
3011
- $metadata: deserializeMetadata(output),
3012
- };
3013
- break;
1933
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
3014
1934
  default:
3015
1935
  const parsedBody = parsedOutput.body;
3016
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3017
- response = {
3018
- ...parsedBody,
3019
- name: `${errorCode}`,
3020
- message: parsedBody.message || parsedBody.Message || errorCode,
1936
+ response = new KMSServiceException_1.KMSServiceException({
1937
+ name: parsedBody.code || parsedBody.Code || errorCode,
3021
1938
  $fault: "client",
3022
1939
  $metadata: deserializeMetadata(output),
3023
- };
1940
+ });
1941
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3024
1942
  }
3025
- const message = response.message || response.Message || errorCode;
3026
- response.message = message;
3027
- delete response.Message;
3028
- return Promise.reject(Object.assign(new Error(message), response));
3029
1943
  };
3030
1944
  const deserializeAws_json1_1ListAliasesCommand = async (output, context) => {
3031
1945
  if (output.statusCode >= 300) {
@@ -3052,59 +1966,28 @@ const deserializeAws_json1_1ListAliasesCommandError = async (output, context) =>
3052
1966
  switch (errorCode) {
3053
1967
  case "DependencyTimeoutException":
3054
1968
  case "com.amazonaws.kms#DependencyTimeoutException":
3055
- response = {
3056
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
3057
- name: errorCode,
3058
- $metadata: deserializeMetadata(output),
3059
- };
3060
- break;
1969
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
3061
1970
  case "InvalidArnException":
3062
1971
  case "com.amazonaws.kms#InvalidArnException":
3063
- response = {
3064
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
3065
- name: errorCode,
3066
- $metadata: deserializeMetadata(output),
3067
- };
3068
- break;
1972
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
3069
1973
  case "InvalidMarkerException":
3070
1974
  case "com.amazonaws.kms#InvalidMarkerException":
3071
- response = {
3072
- ...(await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context)),
3073
- name: errorCode,
3074
- $metadata: deserializeMetadata(output),
3075
- };
3076
- break;
1975
+ throw await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context);
3077
1976
  case "KMSInternalException":
3078
1977
  case "com.amazonaws.kms#KMSInternalException":
3079
- response = {
3080
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3081
- name: errorCode,
3082
- $metadata: deserializeMetadata(output),
3083
- };
3084
- break;
1978
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3085
1979
  case "NotFoundException":
3086
1980
  case "com.amazonaws.kms#NotFoundException":
3087
- response = {
3088
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3089
- name: errorCode,
3090
- $metadata: deserializeMetadata(output),
3091
- };
3092
- break;
1981
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3093
1982
  default:
3094
1983
  const parsedBody = parsedOutput.body;
3095
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3096
- response = {
3097
- ...parsedBody,
3098
- name: `${errorCode}`,
3099
- message: parsedBody.message || parsedBody.Message || errorCode,
1984
+ response = new KMSServiceException_1.KMSServiceException({
1985
+ name: parsedBody.code || parsedBody.Code || errorCode,
3100
1986
  $fault: "client",
3101
1987
  $metadata: deserializeMetadata(output),
3102
- };
1988
+ });
1989
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3103
1990
  }
3104
- const message = response.message || response.Message || errorCode;
3105
- response.message = message;
3106
- delete response.Message;
3107
- return Promise.reject(Object.assign(new Error(message), response));
3108
1991
  };
3109
1992
  const deserializeAws_json1_1ListGrantsCommand = async (output, context) => {
3110
1993
  if (output.statusCode >= 300) {
@@ -3131,75 +2014,34 @@ const deserializeAws_json1_1ListGrantsCommandError = async (output, context) =>
3131
2014
  switch (errorCode) {
3132
2015
  case "DependencyTimeoutException":
3133
2016
  case "com.amazonaws.kms#DependencyTimeoutException":
3134
- response = {
3135
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
3136
- name: errorCode,
3137
- $metadata: deserializeMetadata(output),
3138
- };
3139
- break;
2017
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
3140
2018
  case "InvalidArnException":
3141
2019
  case "com.amazonaws.kms#InvalidArnException":
3142
- response = {
3143
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
3144
- name: errorCode,
3145
- $metadata: deserializeMetadata(output),
3146
- };
3147
- break;
2020
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
3148
2021
  case "InvalidGrantIdException":
3149
2022
  case "com.amazonaws.kms#InvalidGrantIdException":
3150
- response = {
3151
- ...(await deserializeAws_json1_1InvalidGrantIdExceptionResponse(parsedOutput, context)),
3152
- name: errorCode,
3153
- $metadata: deserializeMetadata(output),
3154
- };
3155
- break;
2023
+ throw await deserializeAws_json1_1InvalidGrantIdExceptionResponse(parsedOutput, context);
3156
2024
  case "InvalidMarkerException":
3157
2025
  case "com.amazonaws.kms#InvalidMarkerException":
3158
- response = {
3159
- ...(await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context)),
3160
- name: errorCode,
3161
- $metadata: deserializeMetadata(output),
3162
- };
3163
- break;
2026
+ throw await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context);
3164
2027
  case "KMSInternalException":
3165
2028
  case "com.amazonaws.kms#KMSInternalException":
3166
- response = {
3167
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3168
- name: errorCode,
3169
- $metadata: deserializeMetadata(output),
3170
- };
3171
- break;
2029
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3172
2030
  case "KMSInvalidStateException":
3173
2031
  case "com.amazonaws.kms#KMSInvalidStateException":
3174
- response = {
3175
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
3176
- name: errorCode,
3177
- $metadata: deserializeMetadata(output),
3178
- };
3179
- break;
2032
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
3180
2033
  case "NotFoundException":
3181
2034
  case "com.amazonaws.kms#NotFoundException":
3182
- response = {
3183
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3184
- name: errorCode,
3185
- $metadata: deserializeMetadata(output),
3186
- };
3187
- break;
2035
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3188
2036
  default:
3189
2037
  const parsedBody = parsedOutput.body;
3190
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3191
- response = {
3192
- ...parsedBody,
3193
- name: `${errorCode}`,
3194
- message: parsedBody.message || parsedBody.Message || errorCode,
2038
+ response = new KMSServiceException_1.KMSServiceException({
2039
+ name: parsedBody.code || parsedBody.Code || errorCode,
3195
2040
  $fault: "client",
3196
2041
  $metadata: deserializeMetadata(output),
3197
- };
2042
+ });
2043
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3198
2044
  }
3199
- const message = response.message || response.Message || errorCode;
3200
- response.message = message;
3201
- delete response.Message;
3202
- return Promise.reject(Object.assign(new Error(message), response));
3203
2045
  };
3204
2046
  const deserializeAws_json1_1ListKeyPoliciesCommand = async (output, context) => {
3205
2047
  if (output.statusCode >= 300) {
@@ -3226,59 +2068,28 @@ const deserializeAws_json1_1ListKeyPoliciesCommandError = async (output, context
3226
2068
  switch (errorCode) {
3227
2069
  case "DependencyTimeoutException":
3228
2070
  case "com.amazonaws.kms#DependencyTimeoutException":
3229
- response = {
3230
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
3231
- name: errorCode,
3232
- $metadata: deserializeMetadata(output),
3233
- };
3234
- break;
2071
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
3235
2072
  case "InvalidArnException":
3236
2073
  case "com.amazonaws.kms#InvalidArnException":
3237
- response = {
3238
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
3239
- name: errorCode,
3240
- $metadata: deserializeMetadata(output),
3241
- };
3242
- break;
2074
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
3243
2075
  case "KMSInternalException":
3244
2076
  case "com.amazonaws.kms#KMSInternalException":
3245
- response = {
3246
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3247
- name: errorCode,
3248
- $metadata: deserializeMetadata(output),
3249
- };
3250
- break;
2077
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3251
2078
  case "KMSInvalidStateException":
3252
2079
  case "com.amazonaws.kms#KMSInvalidStateException":
3253
- response = {
3254
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
3255
- name: errorCode,
3256
- $metadata: deserializeMetadata(output),
3257
- };
3258
- break;
2080
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
3259
2081
  case "NotFoundException":
3260
2082
  case "com.amazonaws.kms#NotFoundException":
3261
- response = {
3262
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3263
- name: errorCode,
3264
- $metadata: deserializeMetadata(output),
3265
- };
3266
- break;
2083
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3267
2084
  default:
3268
2085
  const parsedBody = parsedOutput.body;
3269
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3270
- response = {
3271
- ...parsedBody,
3272
- name: `${errorCode}`,
3273
- message: parsedBody.message || parsedBody.Message || errorCode,
2086
+ response = new KMSServiceException_1.KMSServiceException({
2087
+ name: parsedBody.code || parsedBody.Code || errorCode,
3274
2088
  $fault: "client",
3275
2089
  $metadata: deserializeMetadata(output),
3276
- };
2090
+ });
2091
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3277
2092
  }
3278
- const message = response.message || response.Message || errorCode;
3279
- response.message = message;
3280
- delete response.Message;
3281
- return Promise.reject(Object.assign(new Error(message), response));
3282
2093
  };
3283
2094
  const deserializeAws_json1_1ListKeysCommand = async (output, context) => {
3284
2095
  if (output.statusCode >= 300) {
@@ -3305,43 +2116,22 @@ const deserializeAws_json1_1ListKeysCommandError = async (output, context) => {
3305
2116
  switch (errorCode) {
3306
2117
  case "DependencyTimeoutException":
3307
2118
  case "com.amazonaws.kms#DependencyTimeoutException":
3308
- response = {
3309
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
3310
- name: errorCode,
3311
- $metadata: deserializeMetadata(output),
3312
- };
3313
- break;
2119
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
3314
2120
  case "InvalidMarkerException":
3315
2121
  case "com.amazonaws.kms#InvalidMarkerException":
3316
- response = {
3317
- ...(await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context)),
3318
- name: errorCode,
3319
- $metadata: deserializeMetadata(output),
3320
- };
3321
- break;
2122
+ throw await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context);
3322
2123
  case "KMSInternalException":
3323
2124
  case "com.amazonaws.kms#KMSInternalException":
3324
- response = {
3325
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3326
- name: errorCode,
3327
- $metadata: deserializeMetadata(output),
3328
- };
3329
- break;
2125
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3330
2126
  default:
3331
2127
  const parsedBody = parsedOutput.body;
3332
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3333
- response = {
3334
- ...parsedBody,
3335
- name: `${errorCode}`,
3336
- message: parsedBody.message || parsedBody.Message || errorCode,
2128
+ response = new KMSServiceException_1.KMSServiceException({
2129
+ name: parsedBody.code || parsedBody.Code || errorCode,
3337
2130
  $fault: "client",
3338
2131
  $metadata: deserializeMetadata(output),
3339
- };
2132
+ });
2133
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3340
2134
  }
3341
- const message = response.message || response.Message || errorCode;
3342
- response.message = message;
3343
- delete response.Message;
3344
- return Promise.reject(Object.assign(new Error(message), response));
3345
2135
  };
3346
2136
  const deserializeAws_json1_1ListResourceTagsCommand = async (output, context) => {
3347
2137
  if (output.statusCode >= 300) {
@@ -3368,51 +2158,25 @@ const deserializeAws_json1_1ListResourceTagsCommandError = async (output, contex
3368
2158
  switch (errorCode) {
3369
2159
  case "InvalidArnException":
3370
2160
  case "com.amazonaws.kms#InvalidArnException":
3371
- response = {
3372
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
3373
- name: errorCode,
3374
- $metadata: deserializeMetadata(output),
3375
- };
3376
- break;
2161
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
3377
2162
  case "InvalidMarkerException":
3378
2163
  case "com.amazonaws.kms#InvalidMarkerException":
3379
- response = {
3380
- ...(await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context)),
3381
- name: errorCode,
3382
- $metadata: deserializeMetadata(output),
3383
- };
3384
- break;
2164
+ throw await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context);
3385
2165
  case "KMSInternalException":
3386
2166
  case "com.amazonaws.kms#KMSInternalException":
3387
- response = {
3388
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3389
- name: errorCode,
3390
- $metadata: deserializeMetadata(output),
3391
- };
3392
- break;
2167
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3393
2168
  case "NotFoundException":
3394
2169
  case "com.amazonaws.kms#NotFoundException":
3395
- response = {
3396
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3397
- name: errorCode,
3398
- $metadata: deserializeMetadata(output),
3399
- };
3400
- break;
2170
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3401
2171
  default:
3402
2172
  const parsedBody = parsedOutput.body;
3403
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3404
- response = {
3405
- ...parsedBody,
3406
- name: `${errorCode}`,
3407
- message: parsedBody.message || parsedBody.Message || errorCode,
2173
+ response = new KMSServiceException_1.KMSServiceException({
2174
+ name: parsedBody.code || parsedBody.Code || errorCode,
3408
2175
  $fault: "client",
3409
2176
  $metadata: deserializeMetadata(output),
3410
- };
2177
+ });
2178
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3411
2179
  }
3412
- const message = response.message || response.Message || errorCode;
3413
- response.message = message;
3414
- delete response.Message;
3415
- return Promise.reject(Object.assign(new Error(message), response));
3416
2180
  };
3417
2181
  const deserializeAws_json1_1ListRetirableGrantsCommand = async (output, context) => {
3418
2182
  if (output.statusCode >= 300) {
@@ -3439,59 +2203,28 @@ const deserializeAws_json1_1ListRetirableGrantsCommandError = async (output, con
3439
2203
  switch (errorCode) {
3440
2204
  case "DependencyTimeoutException":
3441
2205
  case "com.amazonaws.kms#DependencyTimeoutException":
3442
- response = {
3443
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
3444
- name: errorCode,
3445
- $metadata: deserializeMetadata(output),
3446
- };
3447
- break;
2206
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
3448
2207
  case "InvalidArnException":
3449
2208
  case "com.amazonaws.kms#InvalidArnException":
3450
- response = {
3451
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
3452
- name: errorCode,
3453
- $metadata: deserializeMetadata(output),
3454
- };
3455
- break;
2209
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
3456
2210
  case "InvalidMarkerException":
3457
2211
  case "com.amazonaws.kms#InvalidMarkerException":
3458
- response = {
3459
- ...(await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context)),
3460
- name: errorCode,
3461
- $metadata: deserializeMetadata(output),
3462
- };
3463
- break;
2212
+ throw await deserializeAws_json1_1InvalidMarkerExceptionResponse(parsedOutput, context);
3464
2213
  case "KMSInternalException":
3465
2214
  case "com.amazonaws.kms#KMSInternalException":
3466
- response = {
3467
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3468
- name: errorCode,
3469
- $metadata: deserializeMetadata(output),
3470
- };
3471
- break;
2215
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3472
2216
  case "NotFoundException":
3473
2217
  case "com.amazonaws.kms#NotFoundException":
3474
- response = {
3475
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3476
- name: errorCode,
3477
- $metadata: deserializeMetadata(output),
3478
- };
3479
- break;
2218
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3480
2219
  default:
3481
2220
  const parsedBody = parsedOutput.body;
3482
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3483
- response = {
3484
- ...parsedBody,
3485
- name: `${errorCode}`,
3486
- message: parsedBody.message || parsedBody.Message || errorCode,
2221
+ response = new KMSServiceException_1.KMSServiceException({
2222
+ name: parsedBody.code || parsedBody.Code || errorCode,
3487
2223
  $fault: "client",
3488
2224
  $metadata: deserializeMetadata(output),
3489
- };
2225
+ });
2226
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3490
2227
  }
3491
- const message = response.message || response.Message || errorCode;
3492
- response.message = message;
3493
- delete response.Message;
3494
- return Promise.reject(Object.assign(new Error(message), response));
3495
2228
  };
3496
2229
  const deserializeAws_json1_1PutKeyPolicyCommand = async (output, context) => {
3497
2230
  if (output.statusCode >= 300) {
@@ -3515,83 +2248,37 @@ const deserializeAws_json1_1PutKeyPolicyCommandError = async (output, context) =
3515
2248
  switch (errorCode) {
3516
2249
  case "DependencyTimeoutException":
3517
2250
  case "com.amazonaws.kms#DependencyTimeoutException":
3518
- response = {
3519
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
3520
- name: errorCode,
3521
- $metadata: deserializeMetadata(output),
3522
- };
3523
- break;
2251
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
3524
2252
  case "InvalidArnException":
3525
2253
  case "com.amazonaws.kms#InvalidArnException":
3526
- response = {
3527
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
3528
- name: errorCode,
3529
- $metadata: deserializeMetadata(output),
3530
- };
3531
- break;
2254
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
3532
2255
  case "KMSInternalException":
3533
2256
  case "com.amazonaws.kms#KMSInternalException":
3534
- response = {
3535
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3536
- name: errorCode,
3537
- $metadata: deserializeMetadata(output),
3538
- };
3539
- break;
2257
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3540
2258
  case "KMSInvalidStateException":
3541
2259
  case "com.amazonaws.kms#KMSInvalidStateException":
3542
- response = {
3543
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
3544
- name: errorCode,
3545
- $metadata: deserializeMetadata(output),
3546
- };
3547
- break;
2260
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
3548
2261
  case "LimitExceededException":
3549
2262
  case "com.amazonaws.kms#LimitExceededException":
3550
- response = {
3551
- ...(await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context)),
3552
- name: errorCode,
3553
- $metadata: deserializeMetadata(output),
3554
- };
3555
- break;
2263
+ throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context);
3556
2264
  case "MalformedPolicyDocumentException":
3557
2265
  case "com.amazonaws.kms#MalformedPolicyDocumentException":
3558
- response = {
3559
- ...(await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse(parsedOutput, context)),
3560
- name: errorCode,
3561
- $metadata: deserializeMetadata(output),
3562
- };
3563
- break;
2266
+ throw await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse(parsedOutput, context);
3564
2267
  case "NotFoundException":
3565
2268
  case "com.amazonaws.kms#NotFoundException":
3566
- response = {
3567
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3568
- name: errorCode,
3569
- $metadata: deserializeMetadata(output),
3570
- };
3571
- break;
2269
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3572
2270
  case "UnsupportedOperationException":
3573
2271
  case "com.amazonaws.kms#UnsupportedOperationException":
3574
- response = {
3575
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
3576
- name: errorCode,
3577
- $metadata: deserializeMetadata(output),
3578
- };
3579
- break;
2272
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
3580
2273
  default:
3581
2274
  const parsedBody = parsedOutput.body;
3582
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3583
- response = {
3584
- ...parsedBody,
3585
- name: `${errorCode}`,
3586
- message: parsedBody.message || parsedBody.Message || errorCode,
2275
+ response = new KMSServiceException_1.KMSServiceException({
2276
+ name: parsedBody.code || parsedBody.Code || errorCode,
3587
2277
  $fault: "client",
3588
2278
  $metadata: deserializeMetadata(output),
3589
- };
2279
+ });
2280
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3590
2281
  }
3591
- const message = response.message || response.Message || errorCode;
3592
- response.message = message;
3593
- delete response.Message;
3594
- return Promise.reject(Object.assign(new Error(message), response));
3595
2282
  };
3596
2283
  const deserializeAws_json1_1ReEncryptCommand = async (output, context) => {
3597
2284
  if (output.statusCode >= 300) {
@@ -3618,99 +2305,43 @@ const deserializeAws_json1_1ReEncryptCommandError = async (output, context) => {
3618
2305
  switch (errorCode) {
3619
2306
  case "DependencyTimeoutException":
3620
2307
  case "com.amazonaws.kms#DependencyTimeoutException":
3621
- response = {
3622
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
3623
- name: errorCode,
3624
- $metadata: deserializeMetadata(output),
3625
- };
3626
- break;
2308
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
3627
2309
  case "DisabledException":
3628
2310
  case "com.amazonaws.kms#DisabledException":
3629
- response = {
3630
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
3631
- name: errorCode,
3632
- $metadata: deserializeMetadata(output),
3633
- };
3634
- break;
2311
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
3635
2312
  case "IncorrectKeyException":
3636
2313
  case "com.amazonaws.kms#IncorrectKeyException":
3637
- response = {
3638
- ...(await deserializeAws_json1_1IncorrectKeyExceptionResponse(parsedOutput, context)),
3639
- name: errorCode,
3640
- $metadata: deserializeMetadata(output),
3641
- };
3642
- break;
2314
+ throw await deserializeAws_json1_1IncorrectKeyExceptionResponse(parsedOutput, context);
3643
2315
  case "InvalidCiphertextException":
3644
2316
  case "com.amazonaws.kms#InvalidCiphertextException":
3645
- response = {
3646
- ...(await deserializeAws_json1_1InvalidCiphertextExceptionResponse(parsedOutput, context)),
3647
- name: errorCode,
3648
- $metadata: deserializeMetadata(output),
3649
- };
3650
- break;
2317
+ throw await deserializeAws_json1_1InvalidCiphertextExceptionResponse(parsedOutput, context);
3651
2318
  case "InvalidGrantTokenException":
3652
2319
  case "com.amazonaws.kms#InvalidGrantTokenException":
3653
- response = {
3654
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
3655
- name: errorCode,
3656
- $metadata: deserializeMetadata(output),
3657
- };
3658
- break;
2320
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
3659
2321
  case "InvalidKeyUsageException":
3660
2322
  case "com.amazonaws.kms#InvalidKeyUsageException":
3661
- response = {
3662
- ...(await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context)),
3663
- name: errorCode,
3664
- $metadata: deserializeMetadata(output),
3665
- };
3666
- break;
2323
+ throw await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context);
3667
2324
  case "KeyUnavailableException":
3668
2325
  case "com.amazonaws.kms#KeyUnavailableException":
3669
- response = {
3670
- ...(await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context)),
3671
- name: errorCode,
3672
- $metadata: deserializeMetadata(output),
3673
- };
3674
- break;
2326
+ throw await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context);
3675
2327
  case "KMSInternalException":
3676
2328
  case "com.amazonaws.kms#KMSInternalException":
3677
- response = {
3678
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3679
- name: errorCode,
3680
- $metadata: deserializeMetadata(output),
3681
- };
3682
- break;
2329
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3683
2330
  case "KMSInvalidStateException":
3684
2331
  case "com.amazonaws.kms#KMSInvalidStateException":
3685
- response = {
3686
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
3687
- name: errorCode,
3688
- $metadata: deserializeMetadata(output),
3689
- };
3690
- break;
2332
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
3691
2333
  case "NotFoundException":
3692
2334
  case "com.amazonaws.kms#NotFoundException":
3693
- response = {
3694
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3695
- name: errorCode,
3696
- $metadata: deserializeMetadata(output),
3697
- };
3698
- break;
2335
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3699
2336
  default:
3700
2337
  const parsedBody = parsedOutput.body;
3701
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3702
- response = {
3703
- ...parsedBody,
3704
- name: `${errorCode}`,
3705
- message: parsedBody.message || parsedBody.Message || errorCode,
2338
+ response = new KMSServiceException_1.KMSServiceException({
2339
+ name: parsedBody.code || parsedBody.Code || errorCode,
3706
2340
  $fault: "client",
3707
2341
  $metadata: deserializeMetadata(output),
3708
- };
2342
+ });
2343
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3709
2344
  }
3710
- const message = response.message || response.Message || errorCode;
3711
- response.message = message;
3712
- delete response.Message;
3713
- return Promise.reject(Object.assign(new Error(message), response));
3714
2345
  };
3715
2346
  const deserializeAws_json1_1ReplicateKeyCommand = async (output, context) => {
3716
2347
  if (output.statusCode >= 300) {
@@ -3737,99 +2368,43 @@ const deserializeAws_json1_1ReplicateKeyCommandError = async (output, context) =
3737
2368
  switch (errorCode) {
3738
2369
  case "AlreadyExistsException":
3739
2370
  case "com.amazonaws.kms#AlreadyExistsException":
3740
- response = {
3741
- ...(await deserializeAws_json1_1AlreadyExistsExceptionResponse(parsedOutput, context)),
3742
- name: errorCode,
3743
- $metadata: deserializeMetadata(output),
3744
- };
3745
- break;
2371
+ throw await deserializeAws_json1_1AlreadyExistsExceptionResponse(parsedOutput, context);
3746
2372
  case "DisabledException":
3747
2373
  case "com.amazonaws.kms#DisabledException":
3748
- response = {
3749
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
3750
- name: errorCode,
3751
- $metadata: deserializeMetadata(output),
3752
- };
3753
- break;
2374
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
3754
2375
  case "InvalidArnException":
3755
2376
  case "com.amazonaws.kms#InvalidArnException":
3756
- response = {
3757
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
3758
- name: errorCode,
3759
- $metadata: deserializeMetadata(output),
3760
- };
3761
- break;
2377
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
3762
2378
  case "KMSInternalException":
3763
2379
  case "com.amazonaws.kms#KMSInternalException":
3764
- response = {
3765
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3766
- name: errorCode,
3767
- $metadata: deserializeMetadata(output),
3768
- };
3769
- break;
2380
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3770
2381
  case "KMSInvalidStateException":
3771
2382
  case "com.amazonaws.kms#KMSInvalidStateException":
3772
- response = {
3773
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
3774
- name: errorCode,
3775
- $metadata: deserializeMetadata(output),
3776
- };
3777
- break;
2383
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
3778
2384
  case "LimitExceededException":
3779
2385
  case "com.amazonaws.kms#LimitExceededException":
3780
- response = {
3781
- ...(await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context)),
3782
- name: errorCode,
3783
- $metadata: deserializeMetadata(output),
3784
- };
3785
- break;
2386
+ throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context);
3786
2387
  case "MalformedPolicyDocumentException":
3787
2388
  case "com.amazonaws.kms#MalformedPolicyDocumentException":
3788
- response = {
3789
- ...(await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse(parsedOutput, context)),
3790
- name: errorCode,
3791
- $metadata: deserializeMetadata(output),
3792
- };
3793
- break;
2389
+ throw await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse(parsedOutput, context);
3794
2390
  case "NotFoundException":
3795
2391
  case "com.amazonaws.kms#NotFoundException":
3796
- response = {
3797
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3798
- name: errorCode,
3799
- $metadata: deserializeMetadata(output),
3800
- };
3801
- break;
2392
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3802
2393
  case "TagException":
3803
2394
  case "com.amazonaws.kms#TagException":
3804
- response = {
3805
- ...(await deserializeAws_json1_1TagExceptionResponse(parsedOutput, context)),
3806
- name: errorCode,
3807
- $metadata: deserializeMetadata(output),
3808
- };
3809
- break;
2395
+ throw await deserializeAws_json1_1TagExceptionResponse(parsedOutput, context);
3810
2396
  case "UnsupportedOperationException":
3811
2397
  case "com.amazonaws.kms#UnsupportedOperationException":
3812
- response = {
3813
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
3814
- name: errorCode,
3815
- $metadata: deserializeMetadata(output),
3816
- };
3817
- break;
2398
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
3818
2399
  default:
3819
2400
  const parsedBody = parsedOutput.body;
3820
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3821
- response = {
3822
- ...parsedBody,
3823
- name: `${errorCode}`,
3824
- message: parsedBody.message || parsedBody.Message || errorCode,
2401
+ response = new KMSServiceException_1.KMSServiceException({
2402
+ name: parsedBody.code || parsedBody.Code || errorCode,
3825
2403
  $fault: "client",
3826
2404
  $metadata: deserializeMetadata(output),
3827
- };
2405
+ });
2406
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3828
2407
  }
3829
- const message = response.message || response.Message || errorCode;
3830
- response.message = message;
3831
- delete response.Message;
3832
- return Promise.reject(Object.assign(new Error(message), response));
3833
2408
  };
3834
2409
  const deserializeAws_json1_1RetireGrantCommand = async (output, context) => {
3835
2410
  if (output.statusCode >= 300) {
@@ -3853,75 +2428,34 @@ const deserializeAws_json1_1RetireGrantCommandError = async (output, context) =>
3853
2428
  switch (errorCode) {
3854
2429
  case "DependencyTimeoutException":
3855
2430
  case "com.amazonaws.kms#DependencyTimeoutException":
3856
- response = {
3857
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
3858
- name: errorCode,
3859
- $metadata: deserializeMetadata(output),
3860
- };
3861
- break;
2431
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
3862
2432
  case "InvalidArnException":
3863
2433
  case "com.amazonaws.kms#InvalidArnException":
3864
- response = {
3865
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
3866
- name: errorCode,
3867
- $metadata: deserializeMetadata(output),
3868
- };
3869
- break;
2434
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
3870
2435
  case "InvalidGrantIdException":
3871
2436
  case "com.amazonaws.kms#InvalidGrantIdException":
3872
- response = {
3873
- ...(await deserializeAws_json1_1InvalidGrantIdExceptionResponse(parsedOutput, context)),
3874
- name: errorCode,
3875
- $metadata: deserializeMetadata(output),
3876
- };
3877
- break;
2437
+ throw await deserializeAws_json1_1InvalidGrantIdExceptionResponse(parsedOutput, context);
3878
2438
  case "InvalidGrantTokenException":
3879
2439
  case "com.amazonaws.kms#InvalidGrantTokenException":
3880
- response = {
3881
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
3882
- name: errorCode,
3883
- $metadata: deserializeMetadata(output),
3884
- };
3885
- break;
2440
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
3886
2441
  case "KMSInternalException":
3887
2442
  case "com.amazonaws.kms#KMSInternalException":
3888
- response = {
3889
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3890
- name: errorCode,
3891
- $metadata: deserializeMetadata(output),
3892
- };
3893
- break;
2443
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3894
2444
  case "KMSInvalidStateException":
3895
2445
  case "com.amazonaws.kms#KMSInvalidStateException":
3896
- response = {
3897
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
3898
- name: errorCode,
3899
- $metadata: deserializeMetadata(output),
3900
- };
3901
- break;
2446
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
3902
2447
  case "NotFoundException":
3903
2448
  case "com.amazonaws.kms#NotFoundException":
3904
- response = {
3905
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3906
- name: errorCode,
3907
- $metadata: deserializeMetadata(output),
3908
- };
3909
- break;
2449
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3910
2450
  default:
3911
2451
  const parsedBody = parsedOutput.body;
3912
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3913
- response = {
3914
- ...parsedBody,
3915
- name: `${errorCode}`,
3916
- message: parsedBody.message || parsedBody.Message || errorCode,
2452
+ response = new KMSServiceException_1.KMSServiceException({
2453
+ name: parsedBody.code || parsedBody.Code || errorCode,
3917
2454
  $fault: "client",
3918
2455
  $metadata: deserializeMetadata(output),
3919
- };
2456
+ });
2457
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
3920
2458
  }
3921
- const message = response.message || response.Message || errorCode;
3922
- response.message = message;
3923
- delete response.Message;
3924
- return Promise.reject(Object.assign(new Error(message), response));
3925
2459
  };
3926
2460
  const deserializeAws_json1_1RevokeGrantCommand = async (output, context) => {
3927
2461
  if (output.statusCode >= 300) {
@@ -3945,67 +2479,31 @@ const deserializeAws_json1_1RevokeGrantCommandError = async (output, context) =>
3945
2479
  switch (errorCode) {
3946
2480
  case "DependencyTimeoutException":
3947
2481
  case "com.amazonaws.kms#DependencyTimeoutException":
3948
- response = {
3949
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
3950
- name: errorCode,
3951
- $metadata: deserializeMetadata(output),
3952
- };
3953
- break;
2482
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
3954
2483
  case "InvalidArnException":
3955
2484
  case "com.amazonaws.kms#InvalidArnException":
3956
- response = {
3957
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
3958
- name: errorCode,
3959
- $metadata: deserializeMetadata(output),
3960
- };
3961
- break;
2485
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
3962
2486
  case "InvalidGrantIdException":
3963
2487
  case "com.amazonaws.kms#InvalidGrantIdException":
3964
- response = {
3965
- ...(await deserializeAws_json1_1InvalidGrantIdExceptionResponse(parsedOutput, context)),
3966
- name: errorCode,
3967
- $metadata: deserializeMetadata(output),
3968
- };
3969
- break;
2488
+ throw await deserializeAws_json1_1InvalidGrantIdExceptionResponse(parsedOutput, context);
3970
2489
  case "KMSInternalException":
3971
2490
  case "com.amazonaws.kms#KMSInternalException":
3972
- response = {
3973
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
3974
- name: errorCode,
3975
- $metadata: deserializeMetadata(output),
3976
- };
3977
- break;
2491
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
3978
2492
  case "KMSInvalidStateException":
3979
2493
  case "com.amazonaws.kms#KMSInvalidStateException":
3980
- response = {
3981
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
3982
- name: errorCode,
3983
- $metadata: deserializeMetadata(output),
3984
- };
3985
- break;
2494
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
3986
2495
  case "NotFoundException":
3987
2496
  case "com.amazonaws.kms#NotFoundException":
3988
- response = {
3989
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
3990
- name: errorCode,
3991
- $metadata: deserializeMetadata(output),
3992
- };
3993
- break;
2497
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
3994
2498
  default:
3995
2499
  const parsedBody = parsedOutput.body;
3996
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
3997
- response = {
3998
- ...parsedBody,
3999
- name: `${errorCode}`,
4000
- message: parsedBody.message || parsedBody.Message || errorCode,
2500
+ response = new KMSServiceException_1.KMSServiceException({
2501
+ name: parsedBody.code || parsedBody.Code || errorCode,
4001
2502
  $fault: "client",
4002
2503
  $metadata: deserializeMetadata(output),
4003
- };
2504
+ });
2505
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
4004
2506
  }
4005
- const message = response.message || response.Message || errorCode;
4006
- response.message = message;
4007
- delete response.Message;
4008
- return Promise.reject(Object.assign(new Error(message), response));
4009
2507
  };
4010
2508
  const deserializeAws_json1_1ScheduleKeyDeletionCommand = async (output, context) => {
4011
2509
  if (output.statusCode >= 300) {
@@ -4032,59 +2530,28 @@ const deserializeAws_json1_1ScheduleKeyDeletionCommandError = async (output, con
4032
2530
  switch (errorCode) {
4033
2531
  case "DependencyTimeoutException":
4034
2532
  case "com.amazonaws.kms#DependencyTimeoutException":
4035
- response = {
4036
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
4037
- name: errorCode,
4038
- $metadata: deserializeMetadata(output),
4039
- };
4040
- break;
2533
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
4041
2534
  case "InvalidArnException":
4042
2535
  case "com.amazonaws.kms#InvalidArnException":
4043
- response = {
4044
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
4045
- name: errorCode,
4046
- $metadata: deserializeMetadata(output),
4047
- };
4048
- break;
2536
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
4049
2537
  case "KMSInternalException":
4050
2538
  case "com.amazonaws.kms#KMSInternalException":
4051
- response = {
4052
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
4053
- name: errorCode,
4054
- $metadata: deserializeMetadata(output),
4055
- };
4056
- break;
2539
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
4057
2540
  case "KMSInvalidStateException":
4058
2541
  case "com.amazonaws.kms#KMSInvalidStateException":
4059
- response = {
4060
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
4061
- name: errorCode,
4062
- $metadata: deserializeMetadata(output),
4063
- };
4064
- break;
2542
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
4065
2543
  case "NotFoundException":
4066
2544
  case "com.amazonaws.kms#NotFoundException":
4067
- response = {
4068
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
4069
- name: errorCode,
4070
- $metadata: deserializeMetadata(output),
4071
- };
4072
- break;
2545
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
4073
2546
  default:
4074
2547
  const parsedBody = parsedOutput.body;
4075
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
4076
- response = {
4077
- ...parsedBody,
4078
- name: `${errorCode}`,
4079
- message: parsedBody.message || parsedBody.Message || errorCode,
2548
+ response = new KMSServiceException_1.KMSServiceException({
2549
+ name: parsedBody.code || parsedBody.Code || errorCode,
4080
2550
  $fault: "client",
4081
2551
  $metadata: deserializeMetadata(output),
4082
- };
2552
+ });
2553
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
4083
2554
  }
4084
- const message = response.message || response.Message || errorCode;
4085
- response.message = message;
4086
- delete response.Message;
4087
- return Promise.reject(Object.assign(new Error(message), response));
4088
2555
  };
4089
2556
  const deserializeAws_json1_1SignCommand = async (output, context) => {
4090
2557
  if (output.statusCode >= 300) {
@@ -4111,83 +2578,37 @@ const deserializeAws_json1_1SignCommandError = async (output, context) => {
4111
2578
  switch (errorCode) {
4112
2579
  case "DependencyTimeoutException":
4113
2580
  case "com.amazonaws.kms#DependencyTimeoutException":
4114
- response = {
4115
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
4116
- name: errorCode,
4117
- $metadata: deserializeMetadata(output),
4118
- };
4119
- break;
2581
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
4120
2582
  case "DisabledException":
4121
2583
  case "com.amazonaws.kms#DisabledException":
4122
- response = {
4123
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
4124
- name: errorCode,
4125
- $metadata: deserializeMetadata(output),
4126
- };
4127
- break;
2584
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
4128
2585
  case "InvalidGrantTokenException":
4129
2586
  case "com.amazonaws.kms#InvalidGrantTokenException":
4130
- response = {
4131
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
4132
- name: errorCode,
4133
- $metadata: deserializeMetadata(output),
4134
- };
4135
- break;
2587
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
4136
2588
  case "InvalidKeyUsageException":
4137
2589
  case "com.amazonaws.kms#InvalidKeyUsageException":
4138
- response = {
4139
- ...(await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context)),
4140
- name: errorCode,
4141
- $metadata: deserializeMetadata(output),
4142
- };
4143
- break;
2590
+ throw await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context);
4144
2591
  case "KeyUnavailableException":
4145
2592
  case "com.amazonaws.kms#KeyUnavailableException":
4146
- response = {
4147
- ...(await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context)),
4148
- name: errorCode,
4149
- $metadata: deserializeMetadata(output),
4150
- };
4151
- break;
2593
+ throw await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context);
4152
2594
  case "KMSInternalException":
4153
2595
  case "com.amazonaws.kms#KMSInternalException":
4154
- response = {
4155
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
4156
- name: errorCode,
4157
- $metadata: deserializeMetadata(output),
4158
- };
4159
- break;
2596
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
4160
2597
  case "KMSInvalidStateException":
4161
2598
  case "com.amazonaws.kms#KMSInvalidStateException":
4162
- response = {
4163
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
4164
- name: errorCode,
4165
- $metadata: deserializeMetadata(output),
4166
- };
4167
- break;
2599
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
4168
2600
  case "NotFoundException":
4169
2601
  case "com.amazonaws.kms#NotFoundException":
4170
- response = {
4171
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
4172
- name: errorCode,
4173
- $metadata: deserializeMetadata(output),
4174
- };
4175
- break;
2602
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
4176
2603
  default:
4177
2604
  const parsedBody = parsedOutput.body;
4178
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
4179
- response = {
4180
- ...parsedBody,
4181
- name: `${errorCode}`,
4182
- message: parsedBody.message || parsedBody.Message || errorCode,
2605
+ response = new KMSServiceException_1.KMSServiceException({
2606
+ name: parsedBody.code || parsedBody.Code || errorCode,
4183
2607
  $fault: "client",
4184
2608
  $metadata: deserializeMetadata(output),
4185
- };
2609
+ });
2610
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
4186
2611
  }
4187
- const message = response.message || response.Message || errorCode;
4188
- response.message = message;
4189
- delete response.Message;
4190
- return Promise.reject(Object.assign(new Error(message), response));
4191
2612
  };
4192
2613
  const deserializeAws_json1_1TagResourceCommand = async (output, context) => {
4193
2614
  if (output.statusCode >= 300) {
@@ -4211,67 +2632,31 @@ const deserializeAws_json1_1TagResourceCommandError = async (output, context) =>
4211
2632
  switch (errorCode) {
4212
2633
  case "InvalidArnException":
4213
2634
  case "com.amazonaws.kms#InvalidArnException":
4214
- response = {
4215
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
4216
- name: errorCode,
4217
- $metadata: deserializeMetadata(output),
4218
- };
4219
- break;
2635
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
4220
2636
  case "KMSInternalException":
4221
2637
  case "com.amazonaws.kms#KMSInternalException":
4222
- response = {
4223
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
4224
- name: errorCode,
4225
- $metadata: deserializeMetadata(output),
4226
- };
4227
- break;
2638
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
4228
2639
  case "KMSInvalidStateException":
4229
2640
  case "com.amazonaws.kms#KMSInvalidStateException":
4230
- response = {
4231
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
4232
- name: errorCode,
4233
- $metadata: deserializeMetadata(output),
4234
- };
4235
- break;
2641
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
4236
2642
  case "LimitExceededException":
4237
2643
  case "com.amazonaws.kms#LimitExceededException":
4238
- response = {
4239
- ...(await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context)),
4240
- name: errorCode,
4241
- $metadata: deserializeMetadata(output),
4242
- };
4243
- break;
2644
+ throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context);
4244
2645
  case "NotFoundException":
4245
2646
  case "com.amazonaws.kms#NotFoundException":
4246
- response = {
4247
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
4248
- name: errorCode,
4249
- $metadata: deserializeMetadata(output),
4250
- };
4251
- break;
2647
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
4252
2648
  case "TagException":
4253
2649
  case "com.amazonaws.kms#TagException":
4254
- response = {
4255
- ...(await deserializeAws_json1_1TagExceptionResponse(parsedOutput, context)),
4256
- name: errorCode,
4257
- $metadata: deserializeMetadata(output),
4258
- };
4259
- break;
2650
+ throw await deserializeAws_json1_1TagExceptionResponse(parsedOutput, context);
4260
2651
  default:
4261
2652
  const parsedBody = parsedOutput.body;
4262
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
4263
- response = {
4264
- ...parsedBody,
4265
- name: `${errorCode}`,
4266
- message: parsedBody.message || parsedBody.Message || errorCode,
2653
+ response = new KMSServiceException_1.KMSServiceException({
2654
+ name: parsedBody.code || parsedBody.Code || errorCode,
4267
2655
  $fault: "client",
4268
2656
  $metadata: deserializeMetadata(output),
4269
- };
2657
+ });
2658
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
4270
2659
  }
4271
- const message = response.message || response.Message || errorCode;
4272
- response.message = message;
4273
- delete response.Message;
4274
- return Promise.reject(Object.assign(new Error(message), response));
4275
2660
  };
4276
2661
  const deserializeAws_json1_1UntagResourceCommand = async (output, context) => {
4277
2662
  if (output.statusCode >= 300) {
@@ -4295,59 +2680,28 @@ const deserializeAws_json1_1UntagResourceCommandError = async (output, context)
4295
2680
  switch (errorCode) {
4296
2681
  case "InvalidArnException":
4297
2682
  case "com.amazonaws.kms#InvalidArnException":
4298
- response = {
4299
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
4300
- name: errorCode,
4301
- $metadata: deserializeMetadata(output),
4302
- };
4303
- break;
2683
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
4304
2684
  case "KMSInternalException":
4305
2685
  case "com.amazonaws.kms#KMSInternalException":
4306
- response = {
4307
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
4308
- name: errorCode,
4309
- $metadata: deserializeMetadata(output),
4310
- };
4311
- break;
2686
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
4312
2687
  case "KMSInvalidStateException":
4313
2688
  case "com.amazonaws.kms#KMSInvalidStateException":
4314
- response = {
4315
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
4316
- name: errorCode,
4317
- $metadata: deserializeMetadata(output),
4318
- };
4319
- break;
2689
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
4320
2690
  case "NotFoundException":
4321
2691
  case "com.amazonaws.kms#NotFoundException":
4322
- response = {
4323
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
4324
- name: errorCode,
4325
- $metadata: deserializeMetadata(output),
4326
- };
4327
- break;
2692
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
4328
2693
  case "TagException":
4329
2694
  case "com.amazonaws.kms#TagException":
4330
- response = {
4331
- ...(await deserializeAws_json1_1TagExceptionResponse(parsedOutput, context)),
4332
- name: errorCode,
4333
- $metadata: deserializeMetadata(output),
4334
- };
4335
- break;
2695
+ throw await deserializeAws_json1_1TagExceptionResponse(parsedOutput, context);
4336
2696
  default:
4337
2697
  const parsedBody = parsedOutput.body;
4338
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
4339
- response = {
4340
- ...parsedBody,
4341
- name: `${errorCode}`,
4342
- message: parsedBody.message || parsedBody.Message || errorCode,
2698
+ response = new KMSServiceException_1.KMSServiceException({
2699
+ name: parsedBody.code || parsedBody.Code || errorCode,
4343
2700
  $fault: "client",
4344
2701
  $metadata: deserializeMetadata(output),
4345
- };
2702
+ });
2703
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
4346
2704
  }
4347
- const message = response.message || response.Message || errorCode;
4348
- response.message = message;
4349
- delete response.Message;
4350
- return Promise.reject(Object.assign(new Error(message), response));
4351
2705
  };
4352
2706
  const deserializeAws_json1_1UpdateAliasCommand = async (output, context) => {
4353
2707
  if (output.statusCode >= 300) {
@@ -4371,59 +2725,28 @@ const deserializeAws_json1_1UpdateAliasCommandError = async (output, context) =>
4371
2725
  switch (errorCode) {
4372
2726
  case "DependencyTimeoutException":
4373
2727
  case "com.amazonaws.kms#DependencyTimeoutException":
4374
- response = {
4375
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
4376
- name: errorCode,
4377
- $metadata: deserializeMetadata(output),
4378
- };
4379
- break;
2728
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
4380
2729
  case "KMSInternalException":
4381
2730
  case "com.amazonaws.kms#KMSInternalException":
4382
- response = {
4383
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
4384
- name: errorCode,
4385
- $metadata: deserializeMetadata(output),
4386
- };
4387
- break;
2731
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
4388
2732
  case "KMSInvalidStateException":
4389
2733
  case "com.amazonaws.kms#KMSInvalidStateException":
4390
- response = {
4391
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
4392
- name: errorCode,
4393
- $metadata: deserializeMetadata(output),
4394
- };
4395
- break;
2734
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
4396
2735
  case "LimitExceededException":
4397
2736
  case "com.amazonaws.kms#LimitExceededException":
4398
- response = {
4399
- ...(await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context)),
4400
- name: errorCode,
4401
- $metadata: deserializeMetadata(output),
4402
- };
4403
- break;
2737
+ throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context);
4404
2738
  case "NotFoundException":
4405
2739
  case "com.amazonaws.kms#NotFoundException":
4406
- response = {
4407
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
4408
- name: errorCode,
4409
- $metadata: deserializeMetadata(output),
4410
- };
4411
- break;
2740
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
4412
2741
  default:
4413
2742
  const parsedBody = parsedOutput.body;
4414
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
4415
- response = {
4416
- ...parsedBody,
4417
- name: `${errorCode}`,
4418
- message: parsedBody.message || parsedBody.Message || errorCode,
2743
+ response = new KMSServiceException_1.KMSServiceException({
2744
+ name: parsedBody.code || parsedBody.Code || errorCode,
4419
2745
  $fault: "client",
4420
2746
  $metadata: deserializeMetadata(output),
4421
- };
2747
+ });
2748
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
4422
2749
  }
4423
- const message = response.message || response.Message || errorCode;
4424
- response.message = message;
4425
- delete response.Message;
4426
- return Promise.reject(Object.assign(new Error(message), response));
4427
2750
  };
4428
2751
  const deserializeAws_json1_1UpdateCustomKeyStoreCommand = async (output, context) => {
4429
2752
  if (output.statusCode >= 300) {
@@ -4450,83 +2773,37 @@ const deserializeAws_json1_1UpdateCustomKeyStoreCommandError = async (output, co
4450
2773
  switch (errorCode) {
4451
2774
  case "CloudHsmClusterInvalidConfigurationException":
4452
2775
  case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException":
4453
- response = {
4454
- ...(await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse(parsedOutput, context)),
4455
- name: errorCode,
4456
- $metadata: deserializeMetadata(output),
4457
- };
4458
- break;
2776
+ throw await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse(parsedOutput, context);
4459
2777
  case "CloudHsmClusterNotActiveException":
4460
2778
  case "com.amazonaws.kms#CloudHsmClusterNotActiveException":
4461
- response = {
4462
- ...(await deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse(parsedOutput, context)),
4463
- name: errorCode,
4464
- $metadata: deserializeMetadata(output),
4465
- };
4466
- break;
2779
+ throw await deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse(parsedOutput, context);
4467
2780
  case "CloudHsmClusterNotFoundException":
4468
2781
  case "com.amazonaws.kms#CloudHsmClusterNotFoundException":
4469
- response = {
4470
- ...(await deserializeAws_json1_1CloudHsmClusterNotFoundExceptionResponse(parsedOutput, context)),
4471
- name: errorCode,
4472
- $metadata: deserializeMetadata(output),
4473
- };
4474
- break;
2782
+ throw await deserializeAws_json1_1CloudHsmClusterNotFoundExceptionResponse(parsedOutput, context);
4475
2783
  case "CloudHsmClusterNotRelatedException":
4476
2784
  case "com.amazonaws.kms#CloudHsmClusterNotRelatedException":
4477
- response = {
4478
- ...(await deserializeAws_json1_1CloudHsmClusterNotRelatedExceptionResponse(parsedOutput, context)),
4479
- name: errorCode,
4480
- $metadata: deserializeMetadata(output),
4481
- };
4482
- break;
2785
+ throw await deserializeAws_json1_1CloudHsmClusterNotRelatedExceptionResponse(parsedOutput, context);
4483
2786
  case "CustomKeyStoreInvalidStateException":
4484
2787
  case "com.amazonaws.kms#CustomKeyStoreInvalidStateException":
4485
- response = {
4486
- ...(await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context)),
4487
- name: errorCode,
4488
- $metadata: deserializeMetadata(output),
4489
- };
4490
- break;
2788
+ throw await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse(parsedOutput, context);
4491
2789
  case "CustomKeyStoreNameInUseException":
4492
2790
  case "com.amazonaws.kms#CustomKeyStoreNameInUseException":
4493
- response = {
4494
- ...(await deserializeAws_json1_1CustomKeyStoreNameInUseExceptionResponse(parsedOutput, context)),
4495
- name: errorCode,
4496
- $metadata: deserializeMetadata(output),
4497
- };
4498
- break;
2791
+ throw await deserializeAws_json1_1CustomKeyStoreNameInUseExceptionResponse(parsedOutput, context);
4499
2792
  case "CustomKeyStoreNotFoundException":
4500
2793
  case "com.amazonaws.kms#CustomKeyStoreNotFoundException":
4501
- response = {
4502
- ...(await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context)),
4503
- name: errorCode,
4504
- $metadata: deserializeMetadata(output),
4505
- };
4506
- break;
2794
+ throw await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse(parsedOutput, context);
4507
2795
  case "KMSInternalException":
4508
2796
  case "com.amazonaws.kms#KMSInternalException":
4509
- response = {
4510
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
4511
- name: errorCode,
4512
- $metadata: deserializeMetadata(output),
4513
- };
4514
- break;
2797
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
4515
2798
  default:
4516
2799
  const parsedBody = parsedOutput.body;
4517
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
4518
- response = {
4519
- ...parsedBody,
4520
- name: `${errorCode}`,
4521
- message: parsedBody.message || parsedBody.Message || errorCode,
2800
+ response = new KMSServiceException_1.KMSServiceException({
2801
+ name: parsedBody.code || parsedBody.Code || errorCode,
4522
2802
  $fault: "client",
4523
2803
  $metadata: deserializeMetadata(output),
4524
- };
2804
+ });
2805
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
4525
2806
  }
4526
- const message = response.message || response.Message || errorCode;
4527
- response.message = message;
4528
- delete response.Message;
4529
- return Promise.reject(Object.assign(new Error(message), response));
4530
2807
  };
4531
2808
  const deserializeAws_json1_1UpdateKeyDescriptionCommand = async (output, context) => {
4532
2809
  if (output.statusCode >= 300) {
@@ -4550,59 +2827,28 @@ const deserializeAws_json1_1UpdateKeyDescriptionCommandError = async (output, co
4550
2827
  switch (errorCode) {
4551
2828
  case "DependencyTimeoutException":
4552
2829
  case "com.amazonaws.kms#DependencyTimeoutException":
4553
- response = {
4554
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
4555
- name: errorCode,
4556
- $metadata: deserializeMetadata(output),
4557
- };
4558
- break;
2830
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
4559
2831
  case "InvalidArnException":
4560
2832
  case "com.amazonaws.kms#InvalidArnException":
4561
- response = {
4562
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
4563
- name: errorCode,
4564
- $metadata: deserializeMetadata(output),
4565
- };
4566
- break;
2833
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
4567
2834
  case "KMSInternalException":
4568
2835
  case "com.amazonaws.kms#KMSInternalException":
4569
- response = {
4570
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
4571
- name: errorCode,
4572
- $metadata: deserializeMetadata(output),
4573
- };
4574
- break;
2836
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
4575
2837
  case "KMSInvalidStateException":
4576
2838
  case "com.amazonaws.kms#KMSInvalidStateException":
4577
- response = {
4578
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
4579
- name: errorCode,
4580
- $metadata: deserializeMetadata(output),
4581
- };
4582
- break;
2839
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
4583
2840
  case "NotFoundException":
4584
2841
  case "com.amazonaws.kms#NotFoundException":
4585
- response = {
4586
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
4587
- name: errorCode,
4588
- $metadata: deserializeMetadata(output),
4589
- };
4590
- break;
2842
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
4591
2843
  default:
4592
2844
  const parsedBody = parsedOutput.body;
4593
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
4594
- response = {
4595
- ...parsedBody,
4596
- name: `${errorCode}`,
4597
- message: parsedBody.message || parsedBody.Message || errorCode,
2845
+ response = new KMSServiceException_1.KMSServiceException({
2846
+ name: parsedBody.code || parsedBody.Code || errorCode,
4598
2847
  $fault: "client",
4599
2848
  $metadata: deserializeMetadata(output),
4600
- };
2849
+ });
2850
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
4601
2851
  }
4602
- const message = response.message || response.Message || errorCode;
4603
- response.message = message;
4604
- delete response.Message;
4605
- return Promise.reject(Object.assign(new Error(message), response));
4606
2852
  };
4607
2853
  const deserializeAws_json1_1UpdatePrimaryRegionCommand = async (output, context) => {
4608
2854
  if (output.statusCode >= 300) {
@@ -4626,67 +2872,31 @@ const deserializeAws_json1_1UpdatePrimaryRegionCommandError = async (output, con
4626
2872
  switch (errorCode) {
4627
2873
  case "DisabledException":
4628
2874
  case "com.amazonaws.kms#DisabledException":
4629
- response = {
4630
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
4631
- name: errorCode,
4632
- $metadata: deserializeMetadata(output),
4633
- };
4634
- break;
2875
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
4635
2876
  case "InvalidArnException":
4636
2877
  case "com.amazonaws.kms#InvalidArnException":
4637
- response = {
4638
- ...(await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context)),
4639
- name: errorCode,
4640
- $metadata: deserializeMetadata(output),
4641
- };
4642
- break;
2878
+ throw await deserializeAws_json1_1InvalidArnExceptionResponse(parsedOutput, context);
4643
2879
  case "KMSInternalException":
4644
2880
  case "com.amazonaws.kms#KMSInternalException":
4645
- response = {
4646
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
4647
- name: errorCode,
4648
- $metadata: deserializeMetadata(output),
4649
- };
4650
- break;
2881
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
4651
2882
  case "KMSInvalidStateException":
4652
2883
  case "com.amazonaws.kms#KMSInvalidStateException":
4653
- response = {
4654
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
4655
- name: errorCode,
4656
- $metadata: deserializeMetadata(output),
4657
- };
4658
- break;
2884
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
4659
2885
  case "NotFoundException":
4660
2886
  case "com.amazonaws.kms#NotFoundException":
4661
- response = {
4662
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
4663
- name: errorCode,
4664
- $metadata: deserializeMetadata(output),
4665
- };
4666
- break;
2887
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
4667
2888
  case "UnsupportedOperationException":
4668
2889
  case "com.amazonaws.kms#UnsupportedOperationException":
4669
- response = {
4670
- ...(await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context)),
4671
- name: errorCode,
4672
- $metadata: deserializeMetadata(output),
4673
- };
4674
- break;
2890
+ throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context);
4675
2891
  default:
4676
2892
  const parsedBody = parsedOutput.body;
4677
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
4678
- response = {
4679
- ...parsedBody,
4680
- name: `${errorCode}`,
4681
- message: parsedBody.message || parsedBody.Message || errorCode,
2893
+ response = new KMSServiceException_1.KMSServiceException({
2894
+ name: parsedBody.code || parsedBody.Code || errorCode,
4682
2895
  $fault: "client",
4683
2896
  $metadata: deserializeMetadata(output),
4684
- };
2897
+ });
2898
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
4685
2899
  }
4686
- const message = response.message || response.Message || errorCode;
4687
- response.message = message;
4688
- delete response.Message;
4689
- return Promise.reject(Object.assign(new Error(message), response));
4690
2900
  };
4691
2901
  const deserializeAws_json1_1VerifyCommand = async (output, context) => {
4692
2902
  if (output.statusCode >= 300) {
@@ -4713,454 +2923,337 @@ const deserializeAws_json1_1VerifyCommandError = async (output, context) => {
4713
2923
  switch (errorCode) {
4714
2924
  case "DependencyTimeoutException":
4715
2925
  case "com.amazonaws.kms#DependencyTimeoutException":
4716
- response = {
4717
- ...(await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context)),
4718
- name: errorCode,
4719
- $metadata: deserializeMetadata(output),
4720
- };
4721
- break;
2926
+ throw await deserializeAws_json1_1DependencyTimeoutExceptionResponse(parsedOutput, context);
4722
2927
  case "DisabledException":
4723
2928
  case "com.amazonaws.kms#DisabledException":
4724
- response = {
4725
- ...(await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context)),
4726
- name: errorCode,
4727
- $metadata: deserializeMetadata(output),
4728
- };
4729
- break;
2929
+ throw await deserializeAws_json1_1DisabledExceptionResponse(parsedOutput, context);
4730
2930
  case "InvalidGrantTokenException":
4731
2931
  case "com.amazonaws.kms#InvalidGrantTokenException":
4732
- response = {
4733
- ...(await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context)),
4734
- name: errorCode,
4735
- $metadata: deserializeMetadata(output),
4736
- };
4737
- break;
2932
+ throw await deserializeAws_json1_1InvalidGrantTokenExceptionResponse(parsedOutput, context);
4738
2933
  case "InvalidKeyUsageException":
4739
2934
  case "com.amazonaws.kms#InvalidKeyUsageException":
4740
- response = {
4741
- ...(await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context)),
4742
- name: errorCode,
4743
- $metadata: deserializeMetadata(output),
4744
- };
4745
- break;
2935
+ throw await deserializeAws_json1_1InvalidKeyUsageExceptionResponse(parsedOutput, context);
4746
2936
  case "KeyUnavailableException":
4747
2937
  case "com.amazonaws.kms#KeyUnavailableException":
4748
- response = {
4749
- ...(await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context)),
4750
- name: errorCode,
4751
- $metadata: deserializeMetadata(output),
4752
- };
4753
- break;
2938
+ throw await deserializeAws_json1_1KeyUnavailableExceptionResponse(parsedOutput, context);
4754
2939
  case "KMSInternalException":
4755
2940
  case "com.amazonaws.kms#KMSInternalException":
4756
- response = {
4757
- ...(await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context)),
4758
- name: errorCode,
4759
- $metadata: deserializeMetadata(output),
4760
- };
4761
- break;
2941
+ throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context);
4762
2942
  case "KMSInvalidSignatureException":
4763
2943
  case "com.amazonaws.kms#KMSInvalidSignatureException":
4764
- response = {
4765
- ...(await deserializeAws_json1_1KMSInvalidSignatureExceptionResponse(parsedOutput, context)),
4766
- name: errorCode,
4767
- $metadata: deserializeMetadata(output),
4768
- };
4769
- break;
2944
+ throw await deserializeAws_json1_1KMSInvalidSignatureExceptionResponse(parsedOutput, context);
4770
2945
  case "KMSInvalidStateException":
4771
2946
  case "com.amazonaws.kms#KMSInvalidStateException":
4772
- response = {
4773
- ...(await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context)),
4774
- name: errorCode,
4775
- $metadata: deserializeMetadata(output),
4776
- };
4777
- break;
2947
+ throw await deserializeAws_json1_1KMSInvalidStateExceptionResponse(parsedOutput, context);
4778
2948
  case "NotFoundException":
4779
2949
  case "com.amazonaws.kms#NotFoundException":
4780
- response = {
4781
- ...(await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context)),
4782
- name: errorCode,
4783
- $metadata: deserializeMetadata(output),
4784
- };
4785
- break;
2950
+ throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context);
4786
2951
  default:
4787
2952
  const parsedBody = parsedOutput.body;
4788
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
4789
- response = {
4790
- ...parsedBody,
4791
- name: `${errorCode}`,
4792
- message: parsedBody.message || parsedBody.Message || errorCode,
2953
+ response = new KMSServiceException_1.KMSServiceException({
2954
+ name: parsedBody.code || parsedBody.Code || errorCode,
4793
2955
  $fault: "client",
4794
2956
  $metadata: deserializeMetadata(output),
4795
- };
2957
+ });
2958
+ throw smithy_client_1.decorateServiceException(response, parsedBody);
4796
2959
  }
4797
- const message = response.message || response.Message || errorCode;
4798
- response.message = message;
4799
- delete response.Message;
4800
- return Promise.reject(Object.assign(new Error(message), response));
4801
2960
  };
4802
2961
  const deserializeAws_json1_1AlreadyExistsExceptionResponse = async (parsedOutput, context) => {
4803
2962
  const body = parsedOutput.body;
4804
2963
  const deserialized = deserializeAws_json1_1AlreadyExistsException(body, context);
4805
- const contents = {
4806
- name: "AlreadyExistsException",
4807
- $fault: "client",
2964
+ const exception = new models_0_1.AlreadyExistsException({
4808
2965
  $metadata: deserializeMetadata(parsedOutput),
4809
2966
  ...deserialized,
4810
- };
4811
- return contents;
2967
+ });
2968
+ return smithy_client_1.decorateServiceException(exception, body);
4812
2969
  };
4813
2970
  const deserializeAws_json1_1CloudHsmClusterInUseExceptionResponse = async (parsedOutput, context) => {
4814
2971
  const body = parsedOutput.body;
4815
2972
  const deserialized = deserializeAws_json1_1CloudHsmClusterInUseException(body, context);
4816
- const contents = {
4817
- name: "CloudHsmClusterInUseException",
4818
- $fault: "client",
2973
+ const exception = new models_0_1.CloudHsmClusterInUseException({
4819
2974
  $metadata: deserializeMetadata(parsedOutput),
4820
2975
  ...deserialized,
4821
- };
4822
- return contents;
2976
+ });
2977
+ return smithy_client_1.decorateServiceException(exception, body);
4823
2978
  };
4824
2979
  const deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse = async (parsedOutput, context) => {
4825
2980
  const body = parsedOutput.body;
4826
2981
  const deserialized = deserializeAws_json1_1CloudHsmClusterInvalidConfigurationException(body, context);
4827
- const contents = {
4828
- name: "CloudHsmClusterInvalidConfigurationException",
4829
- $fault: "client",
2982
+ const exception = new models_0_1.CloudHsmClusterInvalidConfigurationException({
4830
2983
  $metadata: deserializeMetadata(parsedOutput),
4831
2984
  ...deserialized,
4832
- };
4833
- return contents;
2985
+ });
2986
+ return smithy_client_1.decorateServiceException(exception, body);
4834
2987
  };
4835
2988
  const deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse = async (parsedOutput, context) => {
4836
2989
  const body = parsedOutput.body;
4837
2990
  const deserialized = deserializeAws_json1_1CloudHsmClusterNotActiveException(body, context);
4838
- const contents = {
4839
- name: "CloudHsmClusterNotActiveException",
4840
- $fault: "client",
2991
+ const exception = new models_0_1.CloudHsmClusterNotActiveException({
4841
2992
  $metadata: deserializeMetadata(parsedOutput),
4842
2993
  ...deserialized,
4843
- };
4844
- return contents;
2994
+ });
2995
+ return smithy_client_1.decorateServiceException(exception, body);
4845
2996
  };
4846
2997
  const deserializeAws_json1_1CloudHsmClusterNotFoundExceptionResponse = async (parsedOutput, context) => {
4847
2998
  const body = parsedOutput.body;
4848
2999
  const deserialized = deserializeAws_json1_1CloudHsmClusterNotFoundException(body, context);
4849
- const contents = {
4850
- name: "CloudHsmClusterNotFoundException",
4851
- $fault: "client",
3000
+ const exception = new models_0_1.CloudHsmClusterNotFoundException({
4852
3001
  $metadata: deserializeMetadata(parsedOutput),
4853
3002
  ...deserialized,
4854
- };
4855
- return contents;
3003
+ });
3004
+ return smithy_client_1.decorateServiceException(exception, body);
4856
3005
  };
4857
3006
  const deserializeAws_json1_1CloudHsmClusterNotRelatedExceptionResponse = async (parsedOutput, context) => {
4858
3007
  const body = parsedOutput.body;
4859
3008
  const deserialized = deserializeAws_json1_1CloudHsmClusterNotRelatedException(body, context);
4860
- const contents = {
4861
- name: "CloudHsmClusterNotRelatedException",
4862
- $fault: "client",
3009
+ const exception = new models_0_1.CloudHsmClusterNotRelatedException({
4863
3010
  $metadata: deserializeMetadata(parsedOutput),
4864
3011
  ...deserialized,
4865
- };
4866
- return contents;
3012
+ });
3013
+ return smithy_client_1.decorateServiceException(exception, body);
4867
3014
  };
4868
3015
  const deserializeAws_json1_1CustomKeyStoreHasCMKsExceptionResponse = async (parsedOutput, context) => {
4869
3016
  const body = parsedOutput.body;
4870
3017
  const deserialized = deserializeAws_json1_1CustomKeyStoreHasCMKsException(body, context);
4871
- const contents = {
4872
- name: "CustomKeyStoreHasCMKsException",
4873
- $fault: "client",
3018
+ const exception = new models_0_1.CustomKeyStoreHasCMKsException({
4874
3019
  $metadata: deserializeMetadata(parsedOutput),
4875
3020
  ...deserialized,
4876
- };
4877
- return contents;
3021
+ });
3022
+ return smithy_client_1.decorateServiceException(exception, body);
4878
3023
  };
4879
3024
  const deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse = async (parsedOutput, context) => {
4880
3025
  const body = parsedOutput.body;
4881
3026
  const deserialized = deserializeAws_json1_1CustomKeyStoreInvalidStateException(body, context);
4882
- const contents = {
4883
- name: "CustomKeyStoreInvalidStateException",
4884
- $fault: "client",
3027
+ const exception = new models_0_1.CustomKeyStoreInvalidStateException({
4885
3028
  $metadata: deserializeMetadata(parsedOutput),
4886
3029
  ...deserialized,
4887
- };
4888
- return contents;
3030
+ });
3031
+ return smithy_client_1.decorateServiceException(exception, body);
4889
3032
  };
4890
3033
  const deserializeAws_json1_1CustomKeyStoreNameInUseExceptionResponse = async (parsedOutput, context) => {
4891
3034
  const body = parsedOutput.body;
4892
3035
  const deserialized = deserializeAws_json1_1CustomKeyStoreNameInUseException(body, context);
4893
- const contents = {
4894
- name: "CustomKeyStoreNameInUseException",
4895
- $fault: "client",
3036
+ const exception = new models_0_1.CustomKeyStoreNameInUseException({
4896
3037
  $metadata: deserializeMetadata(parsedOutput),
4897
3038
  ...deserialized,
4898
- };
4899
- return contents;
3039
+ });
3040
+ return smithy_client_1.decorateServiceException(exception, body);
4900
3041
  };
4901
3042
  const deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse = async (parsedOutput, context) => {
4902
3043
  const body = parsedOutput.body;
4903
3044
  const deserialized = deserializeAws_json1_1CustomKeyStoreNotFoundException(body, context);
4904
- const contents = {
4905
- name: "CustomKeyStoreNotFoundException",
4906
- $fault: "client",
3045
+ const exception = new models_0_1.CustomKeyStoreNotFoundException({
4907
3046
  $metadata: deserializeMetadata(parsedOutput),
4908
3047
  ...deserialized,
4909
- };
4910
- return contents;
3048
+ });
3049
+ return smithy_client_1.decorateServiceException(exception, body);
4911
3050
  };
4912
3051
  const deserializeAws_json1_1DependencyTimeoutExceptionResponse = async (parsedOutput, context) => {
4913
3052
  const body = parsedOutput.body;
4914
3053
  const deserialized = deserializeAws_json1_1DependencyTimeoutException(body, context);
4915
- const contents = {
4916
- name: "DependencyTimeoutException",
4917
- $fault: "server",
3054
+ const exception = new models_0_1.DependencyTimeoutException({
4918
3055
  $metadata: deserializeMetadata(parsedOutput),
4919
3056
  ...deserialized,
4920
- };
4921
- return contents;
3057
+ });
3058
+ return smithy_client_1.decorateServiceException(exception, body);
4922
3059
  };
4923
3060
  const deserializeAws_json1_1DisabledExceptionResponse = async (parsedOutput, context) => {
4924
3061
  const body = parsedOutput.body;
4925
3062
  const deserialized = deserializeAws_json1_1DisabledException(body, context);
4926
- const contents = {
4927
- name: "DisabledException",
4928
- $fault: "client",
3063
+ const exception = new models_0_1.DisabledException({
4929
3064
  $metadata: deserializeMetadata(parsedOutput),
4930
3065
  ...deserialized,
4931
- };
4932
- return contents;
3066
+ });
3067
+ return smithy_client_1.decorateServiceException(exception, body);
4933
3068
  };
4934
3069
  const deserializeAws_json1_1ExpiredImportTokenExceptionResponse = async (parsedOutput, context) => {
4935
3070
  const body = parsedOutput.body;
4936
3071
  const deserialized = deserializeAws_json1_1ExpiredImportTokenException(body, context);
4937
- const contents = {
4938
- name: "ExpiredImportTokenException",
4939
- $fault: "client",
3072
+ const exception = new models_0_1.ExpiredImportTokenException({
4940
3073
  $metadata: deserializeMetadata(parsedOutput),
4941
3074
  ...deserialized,
4942
- };
4943
- return contents;
3075
+ });
3076
+ return smithy_client_1.decorateServiceException(exception, body);
4944
3077
  };
4945
3078
  const deserializeAws_json1_1IncorrectKeyExceptionResponse = async (parsedOutput, context) => {
4946
3079
  const body = parsedOutput.body;
4947
3080
  const deserialized = deserializeAws_json1_1IncorrectKeyException(body, context);
4948
- const contents = {
4949
- name: "IncorrectKeyException",
4950
- $fault: "client",
3081
+ const exception = new models_0_1.IncorrectKeyException({
4951
3082
  $metadata: deserializeMetadata(parsedOutput),
4952
3083
  ...deserialized,
4953
- };
4954
- return contents;
3084
+ });
3085
+ return smithy_client_1.decorateServiceException(exception, body);
4955
3086
  };
4956
3087
  const deserializeAws_json1_1IncorrectKeyMaterialExceptionResponse = async (parsedOutput, context) => {
4957
3088
  const body = parsedOutput.body;
4958
3089
  const deserialized = deserializeAws_json1_1IncorrectKeyMaterialException(body, context);
4959
- const contents = {
4960
- name: "IncorrectKeyMaterialException",
4961
- $fault: "client",
3090
+ const exception = new models_0_1.IncorrectKeyMaterialException({
4962
3091
  $metadata: deserializeMetadata(parsedOutput),
4963
3092
  ...deserialized,
4964
- };
4965
- return contents;
3093
+ });
3094
+ return smithy_client_1.decorateServiceException(exception, body);
4966
3095
  };
4967
3096
  const deserializeAws_json1_1IncorrectTrustAnchorExceptionResponse = async (parsedOutput, context) => {
4968
3097
  const body = parsedOutput.body;
4969
3098
  const deserialized = deserializeAws_json1_1IncorrectTrustAnchorException(body, context);
4970
- const contents = {
4971
- name: "IncorrectTrustAnchorException",
4972
- $fault: "client",
3099
+ const exception = new models_0_1.IncorrectTrustAnchorException({
4973
3100
  $metadata: deserializeMetadata(parsedOutput),
4974
3101
  ...deserialized,
4975
- };
4976
- return contents;
3102
+ });
3103
+ return smithy_client_1.decorateServiceException(exception, body);
4977
3104
  };
4978
3105
  const deserializeAws_json1_1InvalidAliasNameExceptionResponse = async (parsedOutput, context) => {
4979
3106
  const body = parsedOutput.body;
4980
3107
  const deserialized = deserializeAws_json1_1InvalidAliasNameException(body, context);
4981
- const contents = {
4982
- name: "InvalidAliasNameException",
4983
- $fault: "client",
3108
+ const exception = new models_0_1.InvalidAliasNameException({
4984
3109
  $metadata: deserializeMetadata(parsedOutput),
4985
3110
  ...deserialized,
4986
- };
4987
- return contents;
3111
+ });
3112
+ return smithy_client_1.decorateServiceException(exception, body);
4988
3113
  };
4989
3114
  const deserializeAws_json1_1InvalidArnExceptionResponse = async (parsedOutput, context) => {
4990
3115
  const body = parsedOutput.body;
4991
3116
  const deserialized = deserializeAws_json1_1InvalidArnException(body, context);
4992
- const contents = {
4993
- name: "InvalidArnException",
4994
- $fault: "client",
3117
+ const exception = new models_0_1.InvalidArnException({
4995
3118
  $metadata: deserializeMetadata(parsedOutput),
4996
3119
  ...deserialized,
4997
- };
4998
- return contents;
3120
+ });
3121
+ return smithy_client_1.decorateServiceException(exception, body);
4999
3122
  };
5000
3123
  const deserializeAws_json1_1InvalidCiphertextExceptionResponse = async (parsedOutput, context) => {
5001
3124
  const body = parsedOutput.body;
5002
3125
  const deserialized = deserializeAws_json1_1InvalidCiphertextException(body, context);
5003
- const contents = {
5004
- name: "InvalidCiphertextException",
5005
- $fault: "client",
3126
+ const exception = new models_0_1.InvalidCiphertextException({
5006
3127
  $metadata: deserializeMetadata(parsedOutput),
5007
3128
  ...deserialized,
5008
- };
5009
- return contents;
3129
+ });
3130
+ return smithy_client_1.decorateServiceException(exception, body);
5010
3131
  };
5011
3132
  const deserializeAws_json1_1InvalidGrantIdExceptionResponse = async (parsedOutput, context) => {
5012
3133
  const body = parsedOutput.body;
5013
3134
  const deserialized = deserializeAws_json1_1InvalidGrantIdException(body, context);
5014
- const contents = {
5015
- name: "InvalidGrantIdException",
5016
- $fault: "client",
3135
+ const exception = new models_0_1.InvalidGrantIdException({
5017
3136
  $metadata: deserializeMetadata(parsedOutput),
5018
3137
  ...deserialized,
5019
- };
5020
- return contents;
3138
+ });
3139
+ return smithy_client_1.decorateServiceException(exception, body);
5021
3140
  };
5022
3141
  const deserializeAws_json1_1InvalidGrantTokenExceptionResponse = async (parsedOutput, context) => {
5023
3142
  const body = parsedOutput.body;
5024
3143
  const deserialized = deserializeAws_json1_1InvalidGrantTokenException(body, context);
5025
- const contents = {
5026
- name: "InvalidGrantTokenException",
5027
- $fault: "client",
3144
+ const exception = new models_0_1.InvalidGrantTokenException({
5028
3145
  $metadata: deserializeMetadata(parsedOutput),
5029
3146
  ...deserialized,
5030
- };
5031
- return contents;
3147
+ });
3148
+ return smithy_client_1.decorateServiceException(exception, body);
5032
3149
  };
5033
3150
  const deserializeAws_json1_1InvalidImportTokenExceptionResponse = async (parsedOutput, context) => {
5034
3151
  const body = parsedOutput.body;
5035
3152
  const deserialized = deserializeAws_json1_1InvalidImportTokenException(body, context);
5036
- const contents = {
5037
- name: "InvalidImportTokenException",
5038
- $fault: "client",
3153
+ const exception = new models_0_1.InvalidImportTokenException({
5039
3154
  $metadata: deserializeMetadata(parsedOutput),
5040
3155
  ...deserialized,
5041
- };
5042
- return contents;
3156
+ });
3157
+ return smithy_client_1.decorateServiceException(exception, body);
5043
3158
  };
5044
3159
  const deserializeAws_json1_1InvalidKeyUsageExceptionResponse = async (parsedOutput, context) => {
5045
3160
  const body = parsedOutput.body;
5046
3161
  const deserialized = deserializeAws_json1_1InvalidKeyUsageException(body, context);
5047
- const contents = {
5048
- name: "InvalidKeyUsageException",
5049
- $fault: "client",
3162
+ const exception = new models_0_1.InvalidKeyUsageException({
5050
3163
  $metadata: deserializeMetadata(parsedOutput),
5051
3164
  ...deserialized,
5052
- };
5053
- return contents;
3165
+ });
3166
+ return smithy_client_1.decorateServiceException(exception, body);
5054
3167
  };
5055
3168
  const deserializeAws_json1_1InvalidMarkerExceptionResponse = async (parsedOutput, context) => {
5056
3169
  const body = parsedOutput.body;
5057
3170
  const deserialized = deserializeAws_json1_1InvalidMarkerException(body, context);
5058
- const contents = {
5059
- name: "InvalidMarkerException",
5060
- $fault: "client",
3171
+ const exception = new models_0_1.InvalidMarkerException({
5061
3172
  $metadata: deserializeMetadata(parsedOutput),
5062
3173
  ...deserialized,
5063
- };
5064
- return contents;
3174
+ });
3175
+ return smithy_client_1.decorateServiceException(exception, body);
5065
3176
  };
5066
3177
  const deserializeAws_json1_1KeyUnavailableExceptionResponse = async (parsedOutput, context) => {
5067
3178
  const body = parsedOutput.body;
5068
3179
  const deserialized = deserializeAws_json1_1KeyUnavailableException(body, context);
5069
- const contents = {
5070
- name: "KeyUnavailableException",
5071
- $fault: "server",
3180
+ const exception = new models_0_1.KeyUnavailableException({
5072
3181
  $metadata: deserializeMetadata(parsedOutput),
5073
3182
  ...deserialized,
5074
- };
5075
- return contents;
3183
+ });
3184
+ return smithy_client_1.decorateServiceException(exception, body);
5076
3185
  };
5077
3186
  const deserializeAws_json1_1KMSInternalExceptionResponse = async (parsedOutput, context) => {
5078
3187
  const body = parsedOutput.body;
5079
3188
  const deserialized = deserializeAws_json1_1KMSInternalException(body, context);
5080
- const contents = {
5081
- name: "KMSInternalException",
5082
- $fault: "server",
3189
+ const exception = new models_0_1.KMSInternalException({
5083
3190
  $metadata: deserializeMetadata(parsedOutput),
5084
3191
  ...deserialized,
5085
- };
5086
- return contents;
3192
+ });
3193
+ return smithy_client_1.decorateServiceException(exception, body);
5087
3194
  };
5088
3195
  const deserializeAws_json1_1KMSInvalidSignatureExceptionResponse = async (parsedOutput, context) => {
5089
3196
  const body = parsedOutput.body;
5090
3197
  const deserialized = deserializeAws_json1_1KMSInvalidSignatureException(body, context);
5091
- const contents = {
5092
- name: "KMSInvalidSignatureException",
5093
- $fault: "client",
3198
+ const exception = new models_0_1.KMSInvalidSignatureException({
5094
3199
  $metadata: deserializeMetadata(parsedOutput),
5095
3200
  ...deserialized,
5096
- };
5097
- return contents;
3201
+ });
3202
+ return smithy_client_1.decorateServiceException(exception, body);
5098
3203
  };
5099
3204
  const deserializeAws_json1_1KMSInvalidStateExceptionResponse = async (parsedOutput, context) => {
5100
3205
  const body = parsedOutput.body;
5101
3206
  const deserialized = deserializeAws_json1_1KMSInvalidStateException(body, context);
5102
- const contents = {
5103
- name: "KMSInvalidStateException",
5104
- $fault: "client",
3207
+ const exception = new models_0_1.KMSInvalidStateException({
5105
3208
  $metadata: deserializeMetadata(parsedOutput),
5106
3209
  ...deserialized,
5107
- };
5108
- return contents;
3210
+ });
3211
+ return smithy_client_1.decorateServiceException(exception, body);
5109
3212
  };
5110
3213
  const deserializeAws_json1_1LimitExceededExceptionResponse = async (parsedOutput, context) => {
5111
3214
  const body = parsedOutput.body;
5112
3215
  const deserialized = deserializeAws_json1_1LimitExceededException(body, context);
5113
- const contents = {
5114
- name: "LimitExceededException",
5115
- $fault: "client",
3216
+ const exception = new models_0_1.LimitExceededException({
5116
3217
  $metadata: deserializeMetadata(parsedOutput),
5117
3218
  ...deserialized,
5118
- };
5119
- return contents;
3219
+ });
3220
+ return smithy_client_1.decorateServiceException(exception, body);
5120
3221
  };
5121
3222
  const deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse = async (parsedOutput, context) => {
5122
3223
  const body = parsedOutput.body;
5123
3224
  const deserialized = deserializeAws_json1_1MalformedPolicyDocumentException(body, context);
5124
- const contents = {
5125
- name: "MalformedPolicyDocumentException",
5126
- $fault: "client",
3225
+ const exception = new models_0_1.MalformedPolicyDocumentException({
5127
3226
  $metadata: deserializeMetadata(parsedOutput),
5128
3227
  ...deserialized,
5129
- };
5130
- return contents;
3228
+ });
3229
+ return smithy_client_1.decorateServiceException(exception, body);
5131
3230
  };
5132
3231
  const deserializeAws_json1_1NotFoundExceptionResponse = async (parsedOutput, context) => {
5133
3232
  const body = parsedOutput.body;
5134
3233
  const deserialized = deserializeAws_json1_1NotFoundException(body, context);
5135
- const contents = {
5136
- name: "NotFoundException",
5137
- $fault: "client",
3234
+ const exception = new models_0_1.NotFoundException({
5138
3235
  $metadata: deserializeMetadata(parsedOutput),
5139
3236
  ...deserialized,
5140
- };
5141
- return contents;
3237
+ });
3238
+ return smithy_client_1.decorateServiceException(exception, body);
5142
3239
  };
5143
3240
  const deserializeAws_json1_1TagExceptionResponse = async (parsedOutput, context) => {
5144
3241
  const body = parsedOutput.body;
5145
3242
  const deserialized = deserializeAws_json1_1TagException(body, context);
5146
- const contents = {
5147
- name: "TagException",
5148
- $fault: "client",
3243
+ const exception = new models_0_1.TagException({
5149
3244
  $metadata: deserializeMetadata(parsedOutput),
5150
3245
  ...deserialized,
5151
- };
5152
- return contents;
3246
+ });
3247
+ return smithy_client_1.decorateServiceException(exception, body);
5153
3248
  };
5154
3249
  const deserializeAws_json1_1UnsupportedOperationExceptionResponse = async (parsedOutput, context) => {
5155
3250
  const body = parsedOutput.body;
5156
3251
  const deserialized = deserializeAws_json1_1UnsupportedOperationException(body, context);
5157
- const contents = {
5158
- name: "UnsupportedOperationException",
5159
- $fault: "client",
3252
+ const exception = new models_0_1.UnsupportedOperationException({
5160
3253
  $metadata: deserializeMetadata(parsedOutput),
5161
3254
  ...deserialized,
5162
- };
5163
- return contents;
3255
+ });
3256
+ return smithy_client_1.decorateServiceException(exception, body);
5164
3257
  };
5165
3258
  const serializeAws_json1_1CancelKeyDeletionRequest = (input, context) => {
5166
3259
  return {
@@ -5665,7 +3758,7 @@ const serializeAws_json1_1VerifyRequest = (input, context) => {
5665
3758
  };
5666
3759
  };
5667
3760
  const deserializeAws_json1_1AliasList = (output, context) => {
5668
- return (output || [])
3761
+ const retVal = (output || [])
5669
3762
  .filter((e) => e != null)
5670
3763
  .map((entry) => {
5671
3764
  if (entry === null) {
@@ -5673,6 +3766,7 @@ const deserializeAws_json1_1AliasList = (output, context) => {
5673
3766
  }
5674
3767
  return deserializeAws_json1_1AliasListEntry(entry, context);
5675
3768
  });
3769
+ return retVal;
5676
3770
  };
5677
3771
  const deserializeAws_json1_1AliasListEntry = (output, context) => {
5678
3772
  return {
@@ -5764,7 +3858,7 @@ const deserializeAws_json1_1CustomKeyStoreNotFoundException = (output, context)
5764
3858
  };
5765
3859
  };
5766
3860
  const deserializeAws_json1_1CustomKeyStoresList = (output, context) => {
5767
- return (output || [])
3861
+ const retVal = (output || [])
5768
3862
  .filter((e) => e != null)
5769
3863
  .map((entry) => {
5770
3864
  if (entry === null) {
@@ -5772,6 +3866,7 @@ const deserializeAws_json1_1CustomKeyStoresList = (output, context) => {
5772
3866
  }
5773
3867
  return deserializeAws_json1_1CustomKeyStoresListEntry(entry, context);
5774
3868
  });
3869
+ return retVal;
5775
3870
  };
5776
3871
  const deserializeAws_json1_1CustomKeyStoresListEntry = (output, context) => {
5777
3872
  return {
@@ -5826,7 +3921,7 @@ const deserializeAws_json1_1DisconnectCustomKeyStoreResponse = (output, context)
5826
3921
  return {};
5827
3922
  };
5828
3923
  const deserializeAws_json1_1EncryptionAlgorithmSpecList = (output, context) => {
5829
- return (output || [])
3924
+ const retVal = (output || [])
5830
3925
  .filter((e) => e != null)
5831
3926
  .map((entry) => {
5832
3927
  if (entry === null) {
@@ -5834,6 +3929,7 @@ const deserializeAws_json1_1EncryptionAlgorithmSpecList = (output, context) => {
5834
3929
  }
5835
3930
  return smithy_client_1.expectString(entry);
5836
3931
  });
3932
+ return retVal;
5837
3933
  };
5838
3934
  const deserializeAws_json1_1EncryptionContextType = (output, context) => {
5839
3935
  return Object.entries(output).reduce((acc, [key, value]) => {
@@ -5953,7 +4049,7 @@ const deserializeAws_json1_1GrantConstraints = (output, context) => {
5953
4049
  };
5954
4050
  };
5955
4051
  const deserializeAws_json1_1GrantList = (output, context) => {
5956
- return (output || [])
4052
+ const retVal = (output || [])
5957
4053
  .filter((e) => e != null)
5958
4054
  .map((entry) => {
5959
4055
  if (entry === null) {
@@ -5961,6 +4057,7 @@ const deserializeAws_json1_1GrantList = (output, context) => {
5961
4057
  }
5962
4058
  return deserializeAws_json1_1GrantListEntry(entry, context);
5963
4059
  });
4060
+ return retVal;
5964
4061
  };
5965
4062
  const deserializeAws_json1_1GrantListEntry = (output, context) => {
5966
4063
  return {
@@ -5982,7 +4079,7 @@ const deserializeAws_json1_1GrantListEntry = (output, context) => {
5982
4079
  };
5983
4080
  };
5984
4081
  const deserializeAws_json1_1GrantOperationList = (output, context) => {
5985
- return (output || [])
4082
+ const retVal = (output || [])
5986
4083
  .filter((e) => e != null)
5987
4084
  .map((entry) => {
5988
4085
  if (entry === null) {
@@ -5990,6 +4087,7 @@ const deserializeAws_json1_1GrantOperationList = (output, context) => {
5990
4087
  }
5991
4088
  return smithy_client_1.expectString(entry);
5992
4089
  });
4090
+ return retVal;
5993
4091
  };
5994
4092
  const deserializeAws_json1_1ImportKeyMaterialResponse = (output, context) => {
5995
4093
  return {};
@@ -6050,7 +4148,7 @@ const deserializeAws_json1_1InvalidMarkerException = (output, context) => {
6050
4148
  };
6051
4149
  };
6052
4150
  const deserializeAws_json1_1KeyList = (output, context) => {
6053
- return (output || [])
4151
+ const retVal = (output || [])
6054
4152
  .filter((e) => e != null)
6055
4153
  .map((entry) => {
6056
4154
  if (entry === null) {
@@ -6058,6 +4156,7 @@ const deserializeAws_json1_1KeyList = (output, context) => {
6058
4156
  }
6059
4157
  return deserializeAws_json1_1KeyListEntry(entry, context);
6060
4158
  });
4159
+ return retVal;
6061
4160
  };
6062
4161
  const deserializeAws_json1_1KeyListEntry = (output, context) => {
6063
4162
  return {
@@ -6196,7 +4295,7 @@ const deserializeAws_json1_1MultiRegionKey = (output, context) => {
6196
4295
  };
6197
4296
  };
6198
4297
  const deserializeAws_json1_1MultiRegionKeyList = (output, context) => {
6199
- return (output || [])
4298
+ const retVal = (output || [])
6200
4299
  .filter((e) => e != null)
6201
4300
  .map((entry) => {
6202
4301
  if (entry === null) {
@@ -6204,6 +4303,7 @@ const deserializeAws_json1_1MultiRegionKeyList = (output, context) => {
6204
4303
  }
6205
4304
  return deserializeAws_json1_1MultiRegionKey(entry, context);
6206
4305
  });
4306
+ return retVal;
6207
4307
  };
6208
4308
  const deserializeAws_json1_1NotFoundException = (output, context) => {
6209
4309
  return {
@@ -6211,7 +4311,7 @@ const deserializeAws_json1_1NotFoundException = (output, context) => {
6211
4311
  };
6212
4312
  };
6213
4313
  const deserializeAws_json1_1PolicyNameList = (output, context) => {
6214
- return (output || [])
4314
+ const retVal = (output || [])
6215
4315
  .filter((e) => e != null)
6216
4316
  .map((entry) => {
6217
4317
  if (entry === null) {
@@ -6219,6 +4319,7 @@ const deserializeAws_json1_1PolicyNameList = (output, context) => {
6219
4319
  }
6220
4320
  return smithy_client_1.expectString(entry);
6221
4321
  });
4322
+ return retVal;
6222
4323
  };
6223
4324
  const deserializeAws_json1_1ReEncryptResponse = (output, context) => {
6224
4325
  return {
@@ -6253,7 +4354,7 @@ const deserializeAws_json1_1ScheduleKeyDeletionResponse = (output, context) => {
6253
4354
  };
6254
4355
  };
6255
4356
  const deserializeAws_json1_1SigningAlgorithmSpecList = (output, context) => {
6256
- return (output || [])
4357
+ const retVal = (output || [])
6257
4358
  .filter((e) => e != null)
6258
4359
  .map((entry) => {
6259
4360
  if (entry === null) {
@@ -6261,6 +4362,7 @@ const deserializeAws_json1_1SigningAlgorithmSpecList = (output, context) => {
6261
4362
  }
6262
4363
  return smithy_client_1.expectString(entry);
6263
4364
  });
4365
+ return retVal;
6264
4366
  };
6265
4367
  const deserializeAws_json1_1SignResponse = (output, context) => {
6266
4368
  return {
@@ -6281,7 +4383,7 @@ const deserializeAws_json1_1TagException = (output, context) => {
6281
4383
  };
6282
4384
  };
6283
4385
  const deserializeAws_json1_1TagList = (output, context) => {
6284
- return (output || [])
4386
+ const retVal = (output || [])
6285
4387
  .filter((e) => e != null)
6286
4388
  .map((entry) => {
6287
4389
  if (entry === null) {
@@ -6289,6 +4391,7 @@ const deserializeAws_json1_1TagList = (output, context) => {
6289
4391
  }
6290
4392
  return deserializeAws_json1_1Tag(entry, context);
6291
4393
  });
4394
+ return retVal;
6292
4395
  };
6293
4396
  const deserializeAws_json1_1UnsupportedOperationException = (output, context) => {
6294
4397
  return {