Skip to content

Commit

Permalink
Fix logging 404 etc (bcgov#1743)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Sep 12, 2024
1 parent 23fefe0 commit 5436bbf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions jobs/payment-jobs/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jobs/payment-jobs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
pay-api = {git = "https://github.com/bcgov/sbc-pay.git", branch = "main", subdirectory = "pay-api"}
pay-api = {git = "https://github.com/seeker25/sbc-pay.git", branch = "fix_logging_404_etc", subdirectory = "pay-api"}
flask = "^3.0.2"
flask-sqlalchemy = "^3.1.1"
sqlalchemy = "^2.0.28"
Expand Down
15 changes: 8 additions & 7 deletions pay-api/src/pay_api/services/oauth_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def post(endpoint, token, auth_header_type: AuthHeaderType, # pylint: disable=t
raise ServiceUnavailableException(exc) from exc
except HTTPError as exc:
current_app.logger.error(
f"HTTPError on POST with status code {response.status_code if response else ''}")
if response and response.status_code >= 500:
f"HTTPError on POST with status code {exc.response.status_code if exc.response else ''}")
if exc.response and exc.response.status_code >= 500:
raise ServiceUnavailableException(exc) from exc
raise exc
finally:
Expand Down Expand Up @@ -123,12 +123,13 @@ def get(endpoint, token, auth_header_type: AuthHeaderType, # pylint:disable=too
current_app.logger.error(exc)
raise ServiceUnavailableException(exc) from exc
except HTTPError as exc:
if not response or response.status_code != 404:
current_app.logger.error(f"HTTPError on GET with status code {response.status_code if response else ''}")
if response is not None:
if response.status_code >= 500:
if not exc.response or exc.response.status_code != 404:
current_app.logger.error('HTTPError on GET with status code '
f"{exc.response.status_code if exc.response else ''}")
if exc.response is not None:
if exc.response.status_code >= 500:
raise ServiceUnavailableException(exc) from exc
if return_none_if_404 and response.status_code == 404:
if return_none_if_404 and exc.response.status_code == 404:
return None
raise exc
finally:
Expand Down

0 comments on commit 5436bbf

Please sign in to comment.