From 4cbbe29d28ac15d5d0220e5b61740ac4ac014f18 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Tue, 10 Nov 2015 19:06:24 +0100 Subject: [PATCH] Localize were the error parsing should be made --- patacrep/songs/chordpro/syntax.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/patacrep/songs/chordpro/syntax.py b/patacrep/songs/chordpro/syntax.py index 37af7192..6c8d2540 100644 --- a/patacrep/songs/chordpro/syntax.py +++ b/patacrep/songs/chordpro/syntax.py @@ -313,7 +313,13 @@ class ChordproParser(Parser): def parse_song(content, filename=None): """Parse song and return its metadata.""" - return ChordproParser(filename).parse( + parser = ChordproParser(filename) + parsed_content = parser.parse( content, lexer=ChordProLexer(filename=filename).lexer, ) + if parsed_content is None: + # There was a fatal error parsing the content + # TODO: implement error handling by looking into parser + raise Exception('The song could not be parsed') + return parsed_content