Skip to content

Commit aed1a8e

Browse files
committed
Refactor ip and port extraction
1 parent 3804510 commit aed1a8e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Sources/AWSLambdaRuntimeCore/NewLambdaRuntime.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ package final class NewLambdaRuntime<Handler>: Sendable where Handler: Streaming
4040

4141
let ipAndPort = runtimeEndpoint.split(separator: ":", maxSplits: 1)
4242
let ip = String(ipAndPort[0])
43-
let port = Int(ipAndPort[1])!
43+
guard let port = Int(ipAndPort[1]) else { throw NewLambdaRuntimeError(code: .invalidPort) }
4444

4545
let handler = self.handlerMutex.withLock { maybeHandler in
4646
defer {

Sources/AWSLambdaRuntimeCore/NewLambdaRuntimeError.swift

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ package struct NewLambdaRuntimeError: Error {
3131

3232
case cannotStartLambdaRuntime
3333
case runtimeCanOnlyBeStartedOnce
34+
case invalidPort
3435
}
3536

3637
package init(code: Code, underlying: (any Error)? = nil) {

0 commit comments

Comments
 (0)