@@ -17,7 +17,7 @@ class XPCService {
1717 let interface : NSXPCInterface
1818 let logger : Logger
1919 weak var delegate : XPCServiceDelegate ?
20-
20+
2121 @XPCServiceActor
2222 private var isInvalidated = false
2323
@@ -101,6 +101,12 @@ private class InvalidatingConnection {
101101
102102struct NoDataError : Error { }
103103
104+ struct EmptyResponseError : Error , LocalizedError {
105+ var errorDescription : String ? {
106+ " The server is not returning a response. The app may be installed in the wrong directory. "
107+ }
108+ }
109+
104110struct AutoFinishContinuation < T> {
105111 var continuation : AsyncThrowingStream < T , Error > . Continuation
106112
@@ -129,7 +135,10 @@ func withXPCServiceConnected<T, P>(
129135 } as! P
130136 fn ( service, . init( continuation: continuation) )
131137 }
132- return try await stream. first ( where: { _ in true } ) !
138+ guard let result = try await stream. first ( where: { _ in true } ) else {
139+ throw EmptyResponseError ( )
140+ }
141+ return result
133142}
134143
135144@XPCServiceActor
@@ -144,9 +153,12 @@ public func testXPCListenerEndpoint(_ endpoint: NSXPCListenerEndpoint) async ->
144153 continuation. finish ( )
145154 }
146155 do {
147- try await stream. first ( where: { _ in true } ) !
156+ guard let _ = try await stream. first ( where: { _ in true } ) else {
157+ throw EmptyResponseError ( )
158+ }
148159 return true
149160 } catch {
150161 return false
151162 }
152163}
164+
0 commit comments