Skip to content

Commit

Permalink
better exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cbini committed Sep 10, 2020
1 parent c89cc7f commit 9cc7281
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions powerschool/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
__version__ = "2.0.0"
__version__ = "2.0.1"

from oauthlib.oauth2 import BackendApplicationClient
from oauthlib.oauth2 import (
BackendApplicationClient,
TokenExpiredError,
InvalidClientError,
)
from requests_oauthlib import OAuth2Session
from requests.auth import HTTPBasicAuth
import requests
Expand Down Expand Up @@ -41,7 +45,7 @@ def authorize(self, auth):
self.metadata = self._metadata()
return "Authorized!"
else:
return "Access token expired!"
raise TokenExpiredError("Access token expired!")

# check for client credentials (tuple)
if isinstance(auth, tuple):
Expand All @@ -62,8 +66,7 @@ def authorize(self, auth):
self.metadata = self._metadata()
return "Authorized!"
else:
# exit - prompt for credientials tuple
raise Exception(
raise InvalidClientError(
"You must provide a valid access token file or client credentials."
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "powerschool"
version = "2.0.0"
version = "2.0.1"
description = "powerschool is a Python client for the PowerSchool API"
homepage = "https://github.com/TEAMSchools/powerschool"
repository = "https://github.com/TEAMSchools/powerschool"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_powerschool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_version():
assert __version__ == "2.0.0"
assert __version__ == "2.0.1"

0 comments on commit 9cc7281

Please sign in to comment.