1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-21 00:19:42 +02:00

refactor ignore_exceptions

This commit is contained in:
Kelly Brazil
2022-02-04 12:14:16 -08:00
parent 671d6dee36
commit a76d46f9ec
19 changed files with 111 additions and 110 deletions

View File

@ -66,7 +66,7 @@ Examples:
import itertools
import csv
import jc.utils
from jc.utils import add_jc_meta
from jc.utils import ignore_exceptions_msg, add_jc_meta
from jc.exceptions import ParseError
@ -113,10 +113,7 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True.
This can be used directly or
(preferably) by being passed to the
@add_jc_meta decorator.
ignore_exceptions: (boolean) ignore parsing exceptions if True
Yields:
@ -161,4 +158,8 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
try:
yield row if raw else _process(row)
except Exception as e:
yield e, row
if not ignore_exceptions:
e.args = (str(e) + ignore_exceptions_msg,)
raise e
yield e, str(row)