Skip to content

Commit c91b10e

Browse files
committed
[com,geocom,gsidna] changed same exceptions to be ConnectionRefusedError
1 parent 95bf014 commit c91b10e

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ The project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1717

1818
- Changed the `Connection` interface definition to require `send_binary`,
1919
`receive_binary` and `exchange_binary` methods
20-
- Changed `open_serial` to raise `ConnectionError` instead of the original
21-
exception when the connection could not be opened
20+
- Changed `open_serial` to raise `ConnectionRefusedError` instead of the
21+
original exception when the connection could not be opened
2222
- Changed all methods of `SerialConnection` to raise the general
2323
`ConnectionEror` and `TimeoutError` instead of serial specific
2424
`SerialException` and`SerialTimeoutException`
25+
- Changed `GeoCom` init to raise `ConnectionRefusedError` instead of
26+
`ConnectionError` when the connection could not be verified
27+
- Changed `GsiOnlineDNA` init to raise `ConnectionRefusedError` instead of
28+
`ConnectionError` when the connection could not be verified
2529
- Updated GeoCOM response parsing to raise exception when the number of
2630
received paramters does not match the number of parsers specified
2731
- Updated `GeoCom` init signature to require keyword arguments

src/geocompy/communication.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def open_serial(
202202
)
203203
sleep(2)
204204
else:
205-
raise ConnectionError("Could not open connection")
205+
raise ConnectionRefusedError("Could not open connection")
206206

207207
wrapper = SerialConnection(
208208
serialport,
@@ -328,7 +328,7 @@ def open_socket(
328328
)
329329
sleep(2)
330330
else:
331-
raise ConnectionError("Could not open connection")
331+
raise ConnectionRefusedError("Could not open connection")
332332

333333
return SocketConnection(
334334
sock,

src/geocompy/geo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def __init__(
247247
self._logger.exception("Exception during connection attempt")
248248
sleep(1)
249249
else:
250-
raise ConnectionError(
250+
raise ConnectionRefusedError(
251251
"Could not verify connection with instrument"
252252
)
253253

src/geocompy/gsi/dna/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __init__(
155155

156156
sleep(1)
157157
else:
158-
raise ConnectionError(
158+
raise ConnectionRefusedError(
159159
"Could not verify connection with instrument"
160160
)
161161

tests/test_dna.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def dna() -> GsiOnlineDNA:
1818
class TestDNA:
1919
def test_init(self) -> None:
2020
conn_bad = FaultyConnection()
21-
with pytest.raises(ConnectionError):
21+
with pytest.raises(ConnectionRefusedError):
2222
GsiOnlineDNA(conn_bad, attempts=1)
2323

2424
conn_good = DummyGsiOnlineConnection(True)

tests/test_geocom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def is_open(self) -> bool:
7878
class TestGeoCom:
7979
def test_init(self) -> None:
8080
conn_bad = FaultyConnection()
81-
with pytest.raises(ConnectionError):
81+
with pytest.raises(ConnectionRefusedError):
8282
GeoCom(conn_bad, attempts=1)
8383

8484
conn_good = DummyGeoComConnection()

0 commit comments

Comments
 (0)