200 try:
201 synced = await client.tree.sync()
202 print(f"Synced {len(synced)} command(s)")
203 except Exception as e:204 print(e)
205
206
35collection = db["BRProgress"]
36try:
37 print(cluster.server_info()) # prints sever info is connection works
38except Exception: 39 print("Unable to connect to the server.")
40
41
166 temp = ast.literal_eval(BuddyRead(mess.strip(), username)())
167 print(temp)
168 embed = discord.Embed.from_dict(temp["embeds"][-1])
169 except Exception as exc_:170 await message.channel.send(
171 "Sorry, couldn't process Book request. Exception: {}".format(
172 exc_))
177 msg = await message.channel.send(temp["content"], embed=embed)
178 await msg.add_reaction("ā
")
179 await message.delete()
180 except Exception as exc_:181 await message.channel.send(
182 "Sorry, couldn't process Buddy read request. Exception: {}"
183 .format(exc_))
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')