gavinzli commited on
Commit
46459dd
·
1 Parent(s): 7eea859

Add error handling for image loading in list_emails function

Browse files
Files changed (1) hide show
  1. app/controllers/mail.py +4 -1
app/controllers/mail.py CHANGED
@@ -139,7 +139,10 @@ def list_emails(service, messages):
139
  if part["mimeType"] == "application/pdf":
140
  attach_docs = PyPDFLoader(path).load()
141
  elif part["mimeType"] == "image/png" or part["mimeType"] == "image/jpeg":
142
- attach_docs = UnstructuredImageLoader(path).load()
 
 
 
143
  elif part["filename"].endswith(".csv"):
144
  attach_docs = CSVLoader(path).load()
145
  elif (
 
139
  if part["mimeType"] == "application/pdf":
140
  attach_docs = PyPDFLoader(path).load()
141
  elif part["mimeType"] == "image/png" or part["mimeType"] == "image/jpeg":
142
+ try:
143
+ attach_docs = UnstructuredImageLoader(path).load()
144
+ except Exception as e:
145
+ logger.error("Error loading image: %s", e)
146
  elif part["filename"].endswith(".csv"):
147
  attach_docs = CSVLoader(path).load()
148
  elif (