Skip to content

Commit 7e40d17

Browse files
authored
Add note when encountering WebSocketBadStatusException
Encountering a WebSocketBadStatusException most likely means that Scratch's cloud is down. Signed-off-by: Boss-1s <[email protected]>
1 parent a736c46 commit 7e40d17

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

scratchattach/cloud/_base.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -335,20 +335,22 @@ def _handshake(self):
335335
self._send_packet(packet)
336336

337337
def connect(self):
338-
self.websocket = websocket.WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE})
339-
self.websocket.connect(
340-
self.cloud_host,
341-
cookie=self.cookie,
342-
origin=self.origin,
343-
enable_multithread=True,
344-
timeout=self.ws_timeout,
345-
header=self.header
346-
)
347-
self._handshake()
348-
self.active_connection = True
349-
if self.print_connect_message:
350-
print("Connected to cloud server ", self.cloud_host)
351-
338+
try:
339+
self.websocket = websocket.WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE})
340+
self.websocket.connect(
341+
self.cloud_host,
342+
cookie=self.cookie,
343+
origin=self.origin,
344+
enable_multithread=True,
345+
timeout=self.ws_timeout,
346+
header=self.header
347+
)
348+
self._handshake()
349+
self.active_connection = True
350+
if self.print_connect_message:
351+
print("Connected to cloud server ", self.cloud_host)
352+
except WebSocketBadStatusException as e:
353+
print(f"Error: {e} --- Scratch's Cloud system may be down. Please try again later.")
352354
def disconnect(self):
353355
self.active_connection = False
354356
if self.recorder is not None:

0 commit comments

Comments
 (0)