Skip to content

Commit

Permalink
Use contextlib.suppress instead of try-except-pass pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonj04 committed Nov 9, 2023
1 parent 4b6bcee commit b88f1c4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/openapi_server/apis/status_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import contextlib

from caselawclient.Client import MarklogicUnauthorizedError
from fastapi import ( # noqa: F401
APIRouter,
Expand Down Expand Up @@ -38,11 +40,9 @@
async def healthcheck_get() -> dict[str, str]:
"""A test endpoint that checks Marklogic is present"""
client = client_for_basic_auth(HTTPBasicCredentials(username="", password=""))
with error_handling():
try:
client.user_can_view_unpublished_judgments("")
except MarklogicUnauthorizedError: # expected error
pass
with error_handling(), contextlib.suppress(MarklogicUnauthorizedError):
# MarklogicUnauthorizedError is an expected error
client.user_can_view_unpublished_judgments("")
return {"status": "/healthcheck: Marklogic OK"}


Expand Down

0 comments on commit b88f1c4

Please sign in to comment.