56 await self.load_extension("cogs." + a[:-3])
57 print(f"Loading {a[:-3]}.py")
58
59 except Exception as e:60 print(f"Unable to load {a}\n{e}")
61 print(traceback.format_exc())
62
127 if font == "default"
128 else pyfiglet.figlet_format(text, font=font)
129 )
130 except Exception as e:131 if isinstance(e, pyfiglet.FontNotFound):
132 return await ctx.send("Font not found! Insert another one.")
133
56 try:
57 with redirect_stdout(stdout):
58 ret = await func()
59 except Exception as e:60 value = stdout.getvalue()
61 await ctx.send(f"```py\n{value}{traceback.format_exc()}\n```")
62 else:
49
50 try:
51 exec(to_compile, env)
52 except Exception as e:53 return await ctx.send(f"```py\n{e.__class__.__name__}: {e}\n```")
54
55 func = env["func"]
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')