120 try:
121 sid, server = await manager.create_new_server(name=server.name, version=server.version,
122 world_generation_settings=server.world_generation_settings)
123 except Exception as e:124 return JSONResponse({
125 "error": str(e)
126 }, 500)
102 await websocket.send_json(resp)
103 old_resp = resp
104 await asyncio.sleep(5)
105 except Exception:106 return
107
108
180
181 try:
182 await server.start()
183 except Exception as e:184 return JSONResponse({"error": e}, 500)
185
186 return JSONResponse({"message": "Server is starting"}, 200)
293 await wrap_json(server.system_load, "system_metrics")
294 while True:
295 await asyncio.sleep(1)
296 except Exception:297 return
298
299
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')