381 if conn_state['connection']:
382 try:
383 conn_state['connection'].close()
384 except Exception as exc:385 io.debug(f'error closing RouterOS connection to {hostname}: {exc}')
386
387 try:
513 try:
514 with open(join(path, FILENAME_REQUIREMENTS)) as f:
515 lines = f.readlines()
516 except Exception:517 pass
518 else:
519 try:
69 def wrapper(*args, **kwargs):
70 try:
71 return f(*args, **kwargs)
72 except Exception: 73 print_exc()
74 exit(1)
75 finally:
44 else:
45 try:
46 return literal_eval(stdout)
47 except Exception: 48 return stdout
49
50 def run(self, command, **kwargs):
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')