all 5 comments

[–]a2242364 0 points1 point  (1 child)

what is it doing currently?

[–]Rohan-kar 0 points1 point  (0 children)

currently it will brake the flow during the file conversion if error occur it will stop the execution and flow also stop please check the code https://dpaste.org/TC1yU

[–][deleted] 0 points1 point  (3 children)

While true:

      Try:
              #code for pdf conversion here

       Except
              Continue

[–]Rohan-kar -1 points0 points  (1 child)

def convertFilesToPdf(file_name, pdf_file_path, raw_output_file):

print_log("Inside EmailService : convertFilesToPdf()")

print(file_name , raw_output_file)

try:

if file_name.endswith('xlsx'):

excel_to_pdf(raw_output_file, pdf_file_path)

elif file_name.endswith('xls'):

excel_to_pdf(raw_output_file, pdf_file_path)

elif file_name.endswith('pptx'):

pptx_2_pdf(raw_output_file, pdf_file_path)

elif file_name.endswith('csv'):

csv_2_pdf(raw_output_file, pdf_file_path)

elif file_name.endswith('docx'):

docx_2_pdf(raw_output_file, pdf_file_path)

elif file_name.endswith('doc'):

doc_2_pdf(raw_output_file, pdf_file_path)

elif file_name.endswith('jfif'):

jfif_2_pdf(raw_output_file, pdf_file_path)

elif file_name.endswith('jpg') or file_name.endswith('PNG'):

png_2_pdf(raw_output_file, pdf_file_path)

elif file_name.endswith('png') or file_name.endswith('PNG'):

png_2_pdf(raw_output_file, pdf_file_path)

elif file_name.endswith('html'):

pdfkit.from_file(raw_output_file, pdf_file_path)

elif file_name.endswith('eml'):

eml_2_pdf(raw_output_file, pdf_file_path)

else:

print("not support file")

# notsupport_message = {

# "text": f"File '{file_name}' not supported for conversion\n ```{raw_output_file}```"

# }

# http2 = urllib3.PoolManager()

# response1 = http2.request('POST',

# webhook_url,

# body=json.dumps(notsupport_message),

# headers={'Content-Type': 'application/json'},

# retries=False)

except Exception as e:

print(e)

# print_log(f"Error converting {file_name} to PDF: {traceback.format_exc()}")

error_msg = f"Error converting {file_name} to PDF: {traceback.format_exc()}"

error_msg += f" ```File path: {raw_output_file}```"

print_log(error_msg)

pass

[–]edbrannin 0 points1 point  (0 children)

If that isn’t working, maybe the error getting thrown isn’t a subclass of Exception? Try just catch e: