Skip to content

Commit

Permalink
Better error messages in CLI. Catching another edge case with a helpf…
Browse files Browse the repository at this point in the history
…ul error.
  • Loading branch information
robotrapta committed Feb 13, 2024
1 parent 0235111 commit 0556b30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/groundlight/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def groundlight():
cli_func = class_func_to_cli(method)
cli_app.command()(cli_func)
cli_app()
except ApiTokenError:
print(API_TOKEN_MISSING_HELP_MESSAGE)
except ApiTokenError as e:
print(e)


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion src/groundlight/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ def __init__(
self.endpoint = sanitize_endpoint_url(endpoint)
configuration = Configuration(host=self.endpoint)

if api_token is None:
if not api_token:
try:
# Retrieve the API token from environment variable
api_token = os.environ[API_TOKEN_VARIABLE_NAME]
except KeyError as e:
raise ApiTokenError(API_TOKEN_MISSING_HELP_MESSAGE) from e
if not api_token:
raise ApiTokenError("No API token found. GROUNDLIGHT_API_TOKEN environment variable is set but blank")
self.api_token_prefix = api_token[:12]

should_disable_tls_verification = disable_tls_verification
Expand Down

0 comments on commit 0556b30

Please sign in to comment.