318 truncation=True,
319 )
320 articles_encoded_step.append(article_encoded)
321 except Exception: # skipcq: FLK-E722 322 print("Failed to tokenize article: {}".format(article))
323 sys.exit(1)
324
182 line_str = linecache.getline(file_path, linecache_index).rstrip("\n")
183 try:
184 line_json = json.loads(line_str)
185 except Exception:186 print("** JSON Loading Error **")
187 print(file_path)
188 print(index)
If the except block catches a very general exception, it is likely to catch any unrelated errors too. Try to be more explicit about which exception(s) you're trying to catch.
If you need to catch every other exception, then mark it as intentional by
adding a # skipcq
comment.
try:
x = a / b
except Exception:
x = a / (b + 1)
try:
line = input('Enter numbers:')
numbers = [int(i) for i in line.split()]
except BaseException:
print('Only use numbers for the input')
try:
x = a / b
except ZeroDivisionError:
x = a / (b + 1)
try:
event_loop.run()
except Exception as exc: # skipcq: PYL-W0703 - Loop can sometimes crash.
sentry.report(exc)
try:
line = input('Enter numbers:')
numbers = [int(i) for i in line.split()]
except ValueError:
print('Only use numbers for the input')