Better handling of attempts to load invalid SWORD folder or zip-file

This commit is contained in:
Tomas Groth 2023-10-12 03:32:14 +00:00 committed by Raoul Snyman
parent 6d1c598f39
commit 78708213a0
2 changed files with 11 additions and 1 deletions

View File

@ -622,7 +622,12 @@ class BibleImportForm(OpenLPWizard):
for key in bible_keys:
self.sword_bible_combo_box.addItem(self.pysword_folder_modules_json[key]['description'], key)
except Exception:
log.exception('Loading SWORD folder failed')
critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Invalid SWORD folder'),
translate('BiblesPlugin.ImportWizardForm',
'The folder selected does not contain a valid SWORD module.'))
self.sword_bible_combo_box.clear()
self.setField('sword_folder_path', None)
def on_sword_zipfile_path_edit_path_changed(self, new_path):
"""
@ -637,7 +642,12 @@ class BibleImportForm(OpenLPWizard):
for key in bible_keys:
self.sword_zipbible_combo_box.addItem(self.pysword_zip_modules_json[key]['description'], key)
except Exception:
log.exception('Loading SWORD zip-file failed')
critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Invalid SWORD zip-file'),
translate('BiblesPlugin.ImportWizardForm',
'The file selected is not a valid SWORD zip-file.'))
self.sword_zipbible_combo_box.clear()
self.setField('sword_zip_path', None)
def register_fields(self):
"""

View File

@ -731,7 +731,7 @@ class SongMediaItem(MediaManagerItem):
footer_template = self.settings.value('songs/footer template')
try:
return mako.template.Template(footer_template).render_unicode(**vars).replace('\n', '')
except mako.exceptions.SyntaxException:
except (mako.exceptions.SyntaxException, mako.exceptions.CompileException):
log.error('Failed to render Song footer html:\n' + mako.exceptions.text_error_template().render())
if show_error:
critical_error_message_box(message=translate('SongsPlugin.MediaItem',