Skip to content

Commit 911445d

Browse files
committed
Make these connection errors distinct from other error types.
1 parent 35cebc9 commit 911445d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,24 +751,24 @@ def socket_write(self, socket_num, buffer, conn_mode=TCP_MODE):
751751
if conn_mode == self.UDP_MODE:
752752
# UDP verifies chunks on write, not bytes
753753
if sent != total_chunks:
754-
raise RuntimeError(
754+
raise ConnectionError(
755755
"Failed to write %d chunks (sent %d)" % (total_chunks, sent)
756756
)
757757
# UDP needs to finalize with this command, does the actual sending
758758
resp = self._send_command_get_response(_SEND_UDP_DATA_CMD, self._socknum_ll)
759759
if resp[0][0] != 1:
760-
raise RuntimeError("Failed to send UDP data")
760+
raise ConnectionError("Failed to send UDP data")
761761
return
762762

763763
if sent != len(buffer):
764764
self.socket_close(socket_num)
765-
raise RuntimeError(
765+
raise ConnectionError(
766766
"Failed to send %d bytes (sent %d)" % (len(buffer), sent)
767767
)
768768

769769
resp = self._send_command_get_response(_DATA_SENT_TCP_CMD, self._socknum_ll)
770770
if resp[0][0] != 1:
771-
raise RuntimeError("Failed to verify data sent")
771+
raise ConnectionError("Failed to verify data sent")
772772

773773
def socket_available(self, socket_num):
774774
"""Determine how many bytes are waiting to be read on the socket"""

0 commit comments

Comments
 (0)