Commit 0f5a2c7c by Erik Hetzner

Throw exception with citation when unable to parse

parent f674b061
import re
import sys
from pyparsing import Group, OneOrMore, Optional, Regex, White, Word, ZeroOrMore
from pyparsing import Group, OneOrMore, Optional, Regex, White, Word, ZeroOrMore, ParseException
from xciterst.citations import CitationInfo, CitationCluster
class CiteParser(object):
......@@ -132,5 +132,9 @@ class CiteParser(object):
topCite = bracketedCite ^ shortCite + shortCiteExtra ^ shortCite + bracketedCite ^ shortCite
raw = topCite.parseString(what, True)
return self._results2cites(list(raw))
try:
raw = topCite.parseString(what, True)
return self._results2cites(list(raw))
except ParseException:
raise Exception('The citation %s was not parseable.'%(what))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment