Skip to content

Commit

Permalink
Raise tempsiteerror at login when 5xx
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanhed committed Feb 12, 2024
1 parent a27b007 commit 8bcf0c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

new: new feature / impr: improvement / fix: bug fix

## v0.5.3 - WIP

- impr: error handling during login now can raise TemporarySiteError

## v0.5.2 - 2024-02-11

- impr: error handling for non-existing account id
Expand Down
5 changes: 5 additions & 0 deletions src/mijnbib/login_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
AuthenticationError,
CanNotConnectError,
IncompatibleSourceError,
TemporarySiteError,
)

_log = logging.getLogger(__name__)
Expand Down Expand Up @@ -113,6 +114,10 @@ def _log_in(self):
_log.debug(f"login (1) oauth_callback_url: {oauth_callback_url}")
_log.debug(f"login (1) oauth_token : {oauth_token}")
_log.debug(f"login (1) hint : {hint}")
if response.status_code >= 500: # we've observed 500, 502 and 503:
raise TemporarySiteError(
f"Expected status code 302 during log in. Got '{response.status_code}'"
)
if response.status_code != 302:
raise IncompatibleSourceError(
f"Expected status code 302 during log in. Got '{response.status_code}'",
Expand Down
1 change: 1 addition & 0 deletions src/mijnbib/mijnbibliotheek.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def login(self) -> None:
AuthenticationError
CanNotConnectError
IncompatibleSourceError
TemporarySiteError
"""
url = (
self.BASE_URL
Expand Down

0 comments on commit 8bcf0c5

Please sign in to comment.