Skip to content

Commit 03afaa9

Browse files
committed
Better error message
1 parent 7bf037b commit 03afaa9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bar.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,17 @@ def crawling_task(self, url='', post_url='', domain='',
124124
while True:
125125
try:
126126
next_line = process.stderr.readline()
127-
# Added try/catch after bug that appears when visiting (probably because latin-1 apostrophe "’"):
127+
# Added try/catch after bug that appears when visiting (because of apostrophe "’"):
128128
# https://www.edi.admin.ch/edi/it/home/fachstellen/ara/domande-e-risposte/Il-SLR-usa-la-definizione-di-antisemitismo-dell%E2%80%99IHRA.html
129129
# Noticed by Jean-Luc.
130-
next_line = next_line.decode(encoding='utf-8')
130+
decoded_line = next_line.decode(encoding='utf-8')
131131

132-
post(post_url, json={'event': 'crawl_update', 'data': next_line})
133-
logfile.write(next_line)
132+
post(post_url, json={'event': 'crawl_update', 'data': decoded_line})
133+
logfile.write(decoded_line)
134134

135135
except UnicodeDecodeError as e:
136136
# Catch Decoding error.
137-
print("UnicodeDecodeError: " + str(e))
137+
print("UnicodeDecodeError: " + str(e) + " The bytes trying to get decoded were: " + next_line.hex())
138138

139139
if process.poll() is not None:
140140
# Subprocess is finished

0 commit comments

Comments
 (0)