Skip to content

Commit a7faeeb

Browse files
Apply suggestions from code review
Co-authored-by: Lucas McDonald <[email protected]>
1 parent c7a025e commit a7faeeb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Examples/runtimes/python/DynamoDBEncryption/src/keyring/raw_rsa_keyring_example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ def should_generate_new_rsa_key_pair() -> bool:
196196

197197
# If only one file is present: throw exception
198198
if private_key_file and not public_key_file:
199-
raise RuntimeError(f"Missing public key file at {EXAMPLE_RSA_PUBLIC_KEY_FILENAME}")
199+
raise ValueError(f"Missing public key file at {EXAMPLE_RSA_PUBLIC_KEY_FILENAME}")
200200
if not private_key_file and public_key_file:
201-
raise RuntimeError(f"Missing private key file at {EXAMPLE_RSA_PRIVATE_KEY_FILENAME}")
201+
raise ValueError(f"Missing private key file at {EXAMPLE_RSA_PRIVATE_KEY_FILENAME}")
202202

203203
# If neither file is present, generate a new key pair
204204
return True
@@ -208,7 +208,7 @@ def generate_rsa_key_pair():
208208
"""Generate a new RSA key pair and save to PEM files."""
209209
# Safety check: Validate neither file is present
210210
if os.path.exists(EXAMPLE_RSA_PRIVATE_KEY_FILENAME) or os.path.exists(EXAMPLE_RSA_PUBLIC_KEY_FILENAME):
211-
raise RuntimeError("generateRsaKeyPair will not overwrite existing PEM files")
211+
raise FileExistsError("generateRsaKeyPair will not overwrite existing PEM files")
212212

213213
# This code will generate a new RSA key pair for example use.
214214
# The public and private key will be written to the files:
@@ -230,7 +230,7 @@ def generate_rsa_key_pair():
230230
with open(EXAMPLE_RSA_PRIVATE_KEY_FILENAME, "wb") as f:
231231
f.write(private_key_pem)
232232
except IOError as e:
233-
raise RuntimeError("IOError while writing private key PEM") from e
233+
raise OSError("IOError while writing private key PEM") from e
234234

235235
# Write public key PEM file
236236
public_key = private_key.public_key()

Examples/runtimes/python/DynamoDBEncryption/src/scan_error_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55
Example demonstrating error handling for failed decryption during DynamoDB Scan operations.
66
7-
Uses the low level Scan operation to show how to retrieve error messages from the
7+
Uses the Scan operation to show how to retrieve error messages from the
88
returned CollectionOfErrors when some of the Scan results do not decrypt successfully.
99
1010
Running this example requires access to the DDB Table whose name is provided in

0 commit comments

Comments
 (0)