Vets-Who-Code / VetsAI

Apache License 2.0
0 stars 1 forks source link

Improve Error Handling for File Uploads #1

Open jeromehardaway opened 1 week ago

jeromehardaway commented 1 week ago

• Enhance Exception Handling: Improve the extract_text_from_pdf and extract_text_from_word functions to handle exceptions gracefully. This should cover cases such as corrupted files, password-protected documents, or unsupported file formats.

• User Feedback: Provide clear, user-friendly error messages within the Streamlit app when file upload errors occur, ensuring users understand the issue.

• Validation Checks: Implement validation to check file size limits and ensure the uploaded file meets the required format and criteria before processing begins.

Relevant Code Sections:

extract_text_from_pdf(file)extract_text_from_word(file)File upload handling in handle_user_input(job_codes)

Acceptance Criteria:

  1. The system should catch and handle exceptions for corrupted, password-protected, or unsupported file formats.
  2. The app should display a clear error message when the upload fails, explaining the reason (e.g., file too large, invalid format).
  3. Validation should occur before file processing, checking the file size and format.
  4. Ensure that any changes do not introduce regressions or negatively impact performance.

Technical Considerations:

• Use try-except blocks in Python to gracefully handle exceptions. • Consider using PyPDF2 for PDFs and python-docx for Word documents if they are not already being used. • Streamlit’s st.error() can be used to display error messages.

jonulak commented 6 days ago

I can work on this one