Send an error message and close the connection
(self, message: str)
| 207 | self.is_closed = True |
| 208 | |
| 209 | async def throw_error(self, message: str) -> None: |
| 210 | """Send an error message and close the connection""" |
| 211 | print(message) |
| 212 | if not self.is_closed: |
| 213 | try: |
| 214 | await self.websocket.send_json({"type": "error", "value": message}) |
| 215 | await self.websocket.close(APP_ERROR_WEB_SOCKET_CODE) |
| 216 | except ( |
| 217 | ConnectionClosedOK, |
| 218 | ConnectionClosedError, |
| 219 | RuntimeError, |
| 220 | WebSocketDisconnect, |
| 221 | ): |
| 222 | print("WebSocket already closed by client") |
| 223 | self.is_closed = True |
| 224 | |
| 225 | async def receive_params(self) -> Dict[str, Any]: |
| 226 | """Receive parameters from the client""" |