forked from openlp/openlp
Use generated exceptions instead to make more specific errors.
This commit is contained in:
parent
95147c996b
commit
235e8c6fcf
@ -70,6 +70,9 @@ class OpenLyricsImport(SongImport):
|
||||
parsed_file = etree.parse(open(file_path, u'r'), parser)
|
||||
xml = unicode(etree.tostring(parsed_file))
|
||||
self.openLyrics.xml_to_song(xml)
|
||||
except etree.XMLSyntaxError, AttributeError:
|
||||
except etree.XMLSyntaxError:
|
||||
log.exception(u'XML syntax error in file %s' % file_path)
|
||||
self.logError(file_path, SongStrings.XMLSyntaxError)
|
||||
except Exception as values:
|
||||
log.exception(u'%s in file %s' % (values[0], file_path))
|
||||
self.logError(file_path, SongStrings.XMLSyntaxError)
|
||||
|
@ -673,9 +673,16 @@ class OpenLyrics(object):
|
||||
sxml = SongXML()
|
||||
verses = {}
|
||||
verse_def_list = []
|
||||
lyrics = song_xml.lyrics
|
||||
try:
|
||||
lyrics = song_xml.lyrics
|
||||
except AttributeError:
|
||||
raise Exception('XML error, missing lyrics item')
|
||||
try:
|
||||
verses = lyrics.verse
|
||||
except AttributeError:
|
||||
raise Exception('XML error, missing verse item')
|
||||
# Loop over the "verse" elements.
|
||||
for verse in lyrics.verse:
|
||||
for verse in verses:
|
||||
text = u''
|
||||
# Loop over the "lines" elements.
|
||||
for lines in verse.lines:
|
||||
|
Loading…
Reference in New Issue
Block a user