MCPcopy Create free account
hub / github.com/abi/screenshot-to-code / throw_error

Method throw_error

backend/routes/generate_code.py:209–223  ·  view source on GitHub ↗

Send an error message and close the connection

(self, message: str)

Source from the content-addressed store, hash-verified

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"""

Calls 1

closeMethod · 0.45