vobject: Add basic error display for broken items

See #300
This commit is contained in:
Markus Unterwaditzer 2015-12-13 01:52:31 +01:00
parent d63b63f7f9
commit c739bbfcac

View file

@ -236,7 +236,8 @@ class _Component(object):
stack = [] stack = []
rv = [] rv = []
for line in lines: try:
for i, line in enumerate(lines):
if line.startswith(u'BEGIN:'): if line.startswith(u'BEGIN:'):
c_name = line[len(u'BEGIN:'):].strip().upper() c_name = line[len(u'BEGIN:'):].strip().upper()
stack.append(cls(c_name, [], [])) stack.append(cls(c_name, [], []))
@ -249,6 +250,9 @@ class _Component(object):
else: else:
if line.strip(): if line.strip():
stack[-1].props.append(line) stack[-1].props.append(line)
except IndexError:
raise ValueError('Parsing error at line {}. Check the debug log '
'for more information.'.format(i + 1))
if multiple: if multiple:
return rv return rv