Skip to content

Commit 77e7a0b

Browse files
lhowardampcode-com
andcommitted
fix connection state error handling: replace force-unwraps with ?? .notConnected fallback
Amp-Thread-ID: https://ampcode.com/threads/T-019d1236-110d-717d-b5cc-faefb53720a3 Co-authored-by: Amp <amp@ampcode.com>
1 parent 9aa81be commit 77e7a0b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/SwiftOCA/OCP.1/Ocp1Connection+Connect.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ extension Ocp1Connection {
255255
break
256256
default:
257257
logger.trace("connection failed whilst attempting to connect: \(connectionState)")
258-
throw connectionState.error!
258+
throw connectionState.error ?? .notConnected
259259
}
260260
}
261261

@@ -372,7 +372,7 @@ extension Ocp1Connection {
372372
} else if currentConnectionState == .connecting {
373373
throw Ocp1Error.connectionAlreadyInProgress
374374
} else if currentConnectionState != .reconnecting {
375-
throw currentConnectionState.error!
375+
throw currentConnectionState.error ?? .notConnected
376376
}
377377

378378
logger

0 commit comments

Comments
 (0)