Skip to content

Commit cf6f497

Browse files
committed
raise to keep traceback + log exception
1 parent 005c856 commit cf6f497

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

extruct/_extruct.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def extract(htmlstring,
6161
return {}
6262
if errors == 'log':
6363
logger.exception(
64-
'Failed to parse html, exception raised {}'.format(e))
64+
f'Failed to parse html, raises {e}')
6565
return {}
6666
if errors == 'strict':
6767
raise e
@@ -99,9 +99,9 @@ def extract(htmlstring,
9999
for syntax, extract, document in processors:
100100
try:
101101
output[syntax] = list(extract(document, base_url=base_url))
102-
except Exception:
102+
except Exception as e:
103103
if errors == 'log':
104-
logger.exception('Failed to extract {}'.format(syntax))
104+
logger.exception(f'Failed to extract {syntax}, raises {e}')
105105
if errors == 'ignore':
106106
pass
107107
if errors == 'strict':
@@ -132,7 +132,7 @@ def extract(htmlstring,
132132
for syntax, uniform, raw, schema_context in uniform_processors:
133133
try:
134134
if syntax == 'opengraph':
135-
output[syntax] = uniform(raw)
135+
output[syntax] = uniform(raw)
136136
else:
137137
output[syntax] = uniform(raw, schema_context)
138138
except Exception as e:
@@ -141,8 +141,8 @@ def extract(htmlstring,
141141
if errors == 'log':
142142
output[syntax] = []
143143
logger.exception(
144-
f'Failed to uniform extracted, exception raised {e}')
144+
f'Failed to uniform extracted for {syntax}, raises {e}')
145145
if errors == 'strict':
146-
raise e
146+
raise
147147

148148
return output

0 commit comments

Comments
 (0)