mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +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
|
import jc.utils
|
||||||
from jc.utils import stream_success, stream_error
|
from jc.utils import stream_success, stream_error
|
||||||
|
from jc.exceptions import ParseError
|
||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
@ -105,7 +106,10 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
|||||||
# parse the input here
|
# 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:
|
except Exception as e:
|
||||||
yield stream_error(e, ignore_exceptions, line)
|
yield stream_error(e, ignore_exceptions, line)
|
||||||
|
Reference in New Issue
Block a user