Skip to content

Commit

Permalink
Merge pull request #5 from IATabachnikov/Fix-fatalError
Browse files Browse the repository at this point in the history
Removed fatalError in start() method
  • Loading branch information
RomanGL authored Mar 15, 2022
2 parents 8dff053 + 61c7de5 commit 21562c0
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions Development/Source/Swifter/MockNetworkServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,19 @@ extension MockNetworkServer: MockNetworkServerProtocol {
}

server = HttpServer()
start(server: server, on: port)
do {
try server?.start(port)
} catch {
server = nil
return nil
}

server?.notFoundHandler = { _ in
.notFound
}

guard let port = try? server?.port() else {
server = nil
return nil
}

Expand All @@ -105,16 +111,6 @@ extension MockNetworkServer: MockNetworkServerProtocol {
removeAllStubs()
server = nil
}

// MARK: Private

private func start(server: HttpServer?, on port: in_port_t) {
do {
try server?.start(port)
} catch {
fatalError("Couldn't start the mock network server. \n\(String(describing: error))")
}
}
}

// MARK: - Private API
Expand Down

0 comments on commit 21562c0

Please sign in to comment.