Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add better error logging #19662

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

cloudmagic80
Copy link
Contributor

@cloudmagic80 cloudmagic80 commented Dec 2, 2024

Summary

  • *This work is behind a feature toggle (flipper): NO

There are several improvements to the stamp_pdf method, enhancing both its efficiency and error handling:

  1. Early Return for File Existence Check:
    Instead of using an if/else block to check if the file exists, it will now use an early return (return unless File.exist?(stamped_template_path)) This simplifies the code and reduces nesting, making it more readable.

  2. Added Robust Error Handling:
    This PR will introduce a rescue block to gracefully handle potential errors during the PDF stamping process. This ensures the application doesn't crash if something goes wrong.

  3. Improved Error Logging:
    Inside the rescue block, there is now log the error message (Rails.logger.error "Error stamping PDF: #{e.message}"), providing more context for debugging by including the specific exception message.

4.More Informative Error Raising:
When re-raising the error, it will provide a more general message (raise "Error stamping PDF: #{stamped_template_path}") that focuses on the action (stamping the PDF) rather than just the file existence. This gives a clearer indication of where the problem occurred.

Related issue(s)

https://github.com/orgs/department-of-veterans-affairs/projects/1533/views/1?sliceBy%5Bvalue%5D=Sprint+5&filterQuery=parent-issue%3A%22department-of-veterans-affairs%2Fva.gov-team%2395910%22&pane=issue&itemId=87423266&issue=department-of-veterans-affairs%7Cva.gov-team%7C97231

Testing done

  • [x ] New code is covered by unit tests
  • Ran 7959f2 and 1010d with supporting doc.

Note: Optional

What areas of the site does it impact?

IVC CHAMPVA forms

@va-vfs-bot va-vfs-bot temporarily deployed to Improve-PDF-stamping-resiliency/main/main December 2, 2024 01:31 Inactive
@cloudmagic80 cloudmagic80 marked this pull request as ready for review December 2, 2024 16:26
@cloudmagic80 cloudmagic80 requested review from a team as code owners December 2, 2024 16:26
This was referenced Dec 4, 2024
Copy link

github-actions bot commented Jan 4, 2025

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants