Skip to content

Commit

Permalink
Add Perspective API error
Browse files Browse the repository at this point in the history
  • Loading branch information
JosselinSomervilleRoberts committed Feb 21, 2024
1 parent 7e0489c commit 17b806f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/image2structure/filter/file_filters/toxicity_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,13 @@ def callback(request_id: str, response: Dict, error: HttpError):
)

with self._client_lock:
batch_request.execute()
try:
batch_request.execute()
# Handle socket.timeout, httplib2.HttpLib2Error, and googleapiclient.errors.HttpError
except (HttpLib2Error, HttpError) as e:
raise FileFilterError(
f"Error was thrown when making a request to Perspective API: {e}"
) from e
batch_response = text_to_response

except (BatchError, HttpLib2Error, HttpError) as e:
Expand Down

0 comments on commit 17b806f

Please sign in to comment.