Skip to content

Commit

Permalink
fix: catch bomb errors
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed Feb 7, 2023
1 parent cf5055b commit c27cfab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion row.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pytesseract
from pdf2image import convert_from_bytes
from pdf2image.exceptions import PDFInfoNotInstalledError, PDFPageCountError, PDFSyntaxError
from PIL.Image import DecompressionBombError

if "PY_ENV" in environ and environ["PY_ENV"] == "production":
client = google.cloud.logging.Client()
Expand Down Expand Up @@ -167,8 +168,8 @@ def convert_pdf_to_jpg_bytes(pdf_as_bytes):

try:
images = convert_from_bytes(pdf_as_bytes, dpi)
except (TypeError, PDFInfoNotInstalledError, PDFPageCountError, PDFSyntaxError) as error:
logging.error(error)
except (TypeError, PDFInfoNotInstalledError, PDFPageCountError, PDFSyntaxError, DecompressionBombError) as error:
messages = error

count = len(images)
Expand Down

0 comments on commit c27cfab

Please sign in to comment.