forked from openlp/openlp
Added error type back the right way, shorter error messages.
This commit is contained in:
parent
2b28482b8b
commit
9be2fef0c8
@ -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)
|
||||
|
@ -676,17 +676,17 @@ class OpenLyrics(object):
|
||||
try:
|
||||
lyrics = song_xml.lyrics
|
||||
except AttributeError:
|
||||
raise OpenLyricsError('XML', 'Missing lyrics item',
|
||||
raise OpenLyricsError(OpenLyricsError.LyricsError,
|
||||
'<lyrics> tag is missing.',
|
||||
unicode(translate('OpenLP.OpenLyricsImportError',
|
||||
'XML tree is missing <lyrics> tag. '
|
||||
'It is not valid OpenLyrics file.')))
|
||||
'<lyrics> tag is missing.')))
|
||||
try:
|
||||
verses = lyrics.verse
|
||||
except AttributeError:
|
||||
raise OpenLyricsError('XML', 'Missing lyrics item',
|
||||
raise OpenLyricsError(OpenLyricsError.VerseError,
|
||||
'<verse> tag is missing.',
|
||||
unicode(translate('OpenLP.OpenLyricsImportError',
|
||||
'XML tree is missing <verse> tag. '
|
||||
'It is not valid OpenLyrics file.')))
|
||||
'<verse> 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
|
||||
|
Loading…
Reference in New Issue
Block a user