diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index 76f074e06..43a6bc51b 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -75,6 +75,6 @@ class OpenLyricsImport(SongImport): log.exception(u'XML syntax error in file %s' % file_path) self.logError(file_path, SongStrings.XMLSyntaxError) except OpenLyricsError as exception: - log.exception(u'OpenLyricsException of type %s: %s in file %s' - % (exception.type, exception.message, file_path)) + log.exception(u'OpenLyricsException %d in file %s: %s' + % (exception.type, file_path, exception.log_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 81e12d49b..4ed3f97d0 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -676,17 +676,17 @@ class OpenLyrics(object): try: lyrics = song_xml.lyrics except AttributeError: - raise OpenLyricsError('XML', 'Missing lyrics item', + raise OpenLyricsError(OpenLyricsError.LyricsError, + ' tag is missing.', unicode(translate('OpenLP.OpenLyricsImportError', - 'XML tree is missing tag. ' - 'It is not valid OpenLyrics file.'))) + ' tag is missing.'))) try: verses = lyrics.verse except AttributeError: - raise OpenLyricsError('XML', 'Missing lyrics item', + raise OpenLyricsError(OpenLyricsError.VerseError, + ' tag is missing.', unicode(translate('OpenLP.OpenLyricsImportError', - 'XML tree is missing tag. ' - 'It is not valid OpenLyrics file.'))) + ' tag is missing.'))) # Loop over the "verse" elements. for verse in verses: text = u'' @@ -807,13 +807,12 @@ class OpenLyrics(object): class OpenLyricsError(Exception): - """ - By now raised only in case of missing lyrics or verse element in XML. - """ - def __init__(self, exception_type, message, display_message): - self.type = exception_type - self.message = message - self.display_message = display_message + # XML tree is missing the lyrics tag + LyricsError = 1 + # XML tree has no verse tags + VerseError = 2 - def __str__(self): - return "%s: %s" % (self.type, self.message) + def __init__(self, type, log_message, display_message): + self.type = type + self.log_message = log_message + self.display_message = display_message