Skip to content

Support fallback language in get_template with try/catch error handling #515

@yakov-sudo

Description

@yakov-sudo

Description

Currently, in the get_template method in post_office/mail.py (around line 200), if a translation lookup fails, the entire operation may fail or throw an exception.

Proposed Solution

We should wrap the template retrieval logic in a try/catch block so that if we don't have a translation for the requested language, we gracefully fall back to the original email template instead of failing completely.

File Reference

if isinstance(template, EmailTemplate):

Benefits

  • Improved robustness and reliability of the email system
  • Graceful degradation when translations are unavailable
  • Better user experience by always sending emails, even if translation fails
  • Prevents application crashes due to missing language translations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions