diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index cc4759d50..fcebefb78 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -77,7 +77,4 @@ class OpenLyricsImport(SongImport): except OpenLyricsError as exception: log.exception(u'OpenLyricsException of type %s: %s in file %s' % (exception.type, exception.message, file_path)) - if exception.type == 'XML': - self.logError(file_path, SongStrings.XMLSyntaxError) - else: - self.logError(file_path, exception.message) + self.logError(file_path, exception.display_message) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 6cab1d11b..66c75d762 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -676,11 +676,17 @@ class OpenLyrics(object): try: lyrics = song_xml.lyrics except AttributeError: - raise OpenLyricsError('XML', 'Missing lyrics item') + raise OpenLyricsError('XML', 'Missing lyrics item', + unicode(translate('OpenLP.OpenLyricsImportError', + 'XML tree is missing tag. ' + 'It is not valid OpenLyrics file.'))) try: verses = lyrics.verse except AttributeError: - raise OpenLyricsError('XML', 'Missing verse item') + raise OpenLyricsError('XML', 'Missing lyrics item', + unicode(translate('OpenLP.OpenLyricsImportError', + 'XML tree is missing tag. ' + 'It is not valid OpenLyrics file.'))) # Loop over the "verse" elements. for verse in verses: text = u'' @@ -804,9 +810,10 @@ class OpenLyricsError(Exception): """ By now raised only in case of missing lyrics or verse element in XML. """ - def __init__(self, exception_type, message): + def __init__(self, exception_type, message, display_message): self.type = exception_type self.message = message + self.display_message = display_message def __str__(self): return "%s: %s" % (self.type, self.message)