Skip to content

Commit

Permalink
Handle unexpected validation errors
Browse files Browse the repository at this point in the history
Handle unexpected validation errors, such as AppSignal's servers
not being reachable.
  • Loading branch information
unflxw committed Mar 7, 2024
1 parent 4b5f6b3 commit 6a0c91a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/appsignal/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ def _valid_push_api_key(self) -> str | NoReturn:
print("Validating API key...")
print()

validation_result = PushApiKeyValidator.validate(config)
try:
validation_result = PushApiKeyValidator.validate(config)
except Exception as e:
print(
"Error while validating Push API key: "
f"{e}"
)
print("Reach us at [email protected] for support.")
raise ExitError(1) from e

if validation_result == "valid":
print("✅ API key is valid!")
return key
Expand All @@ -76,7 +85,7 @@ def _valid_push_api_key(self) -> str | NoReturn:
else:
print(
"Error while validating Push API key. HTTP status code: "
"{validation_result}"
f"{validation_result}"
)
print("Reach us at [email protected] for support.")
raise ExitError(1)
Expand Down

0 comments on commit 6a0c91a

Please sign in to comment.