Skip to content

Commit

Permalink
fix: add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
johnson2427 committed Jul 1, 2024
1 parent c6b1a2d commit 9850fca
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ape_aws/kms/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,15 @@ def import_key(
private_key=private_key, # type: ignore
import_token=import_token, # type: ignore
)
response = kms_client.import_key(import_key_spec)
if response["ResponseMetadata"]["HTTPStatusCode"] != 200:
cli_ctx.abort("Key failed to import into KMS")
cli_ctx.logger.success(f"Key imported successfully with ID: {key_id}")
try:
response = kms_client.import_key(import_key_spec)
if response["ResponseMetadata"]["HTTPStatusCode"] != 200:
cli_ctx.abort(
f"Key failed to import into KMS, {response['Error']}"
)
cli_ctx.logger.success(f"Key imported successfully with ID: {key_id}")
except Exception as e:
cli_ctx.logger.error(f"Key failed to import into KMS: {e}")


# TODO: Add `ape aws kms sign-message [message]`
Expand Down

0 comments on commit 9850fca

Please sign in to comment.