mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-06 22:32:54 +02:00
Add example to raise ParseError if there is no output data to yield
This commit is contained in:
@ -37,6 +37,7 @@ Examples:
|
||||
"""
|
||||
import jc.utils
|
||||
from jc.utils import stream_success, stream_error
|
||||
from jc.exceptions import ParseError
|
||||
|
||||
|
||||
class info():
|
||||
@ -105,7 +106,10 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
||||
# parse the input here
|
||||
#
|
||||
|
||||
yield stream_success(output_line, ignore_exceptions) if raw else stream_success(_process(output_line), ignore_exceptions)
|
||||
if output_line:
|
||||
yield stream_success(output_line, ignore_exceptions) if raw else stream_success(_process(output_line), ignore_exceptions)
|
||||
else:
|
||||
raise ParseError('Not foo data')
|
||||
|
||||
except Exception as e:
|
||||
yield stream_error(e, ignore_exceptions, line)
|
||||
|
Reference in New Issue
Block a user