code42 / incydr_python

Incydr Python SDK
MIT License
7 stars 5 forks source link

clearer error handling when authentication vars are missing #103

Closed timabrmsn closed 1 year ago

timabrmsn commented 1 year ago

Adds an AuthMissingError exception type that the client raises when any auth vars are missing.

We then catch this in the CLI and present a useful error to the user:

incydr users list    
ERROR: Missing authentication variables in environment.

  - INCYDR_API_CLIENT_SECRET
  - INCYDR_URL

See https://developer.code42.com/cli/getting_started/#authentication

This PR also exposes the _incydr_sdk.exceptions module at incydr.exceptions, making it easier for users to catch our custom exceptions.

It also moves our internal custom error logging methods from the incydr.Client object to the IncydrSettings object, so it's easier to log without having to instantiate a Client.