Skip to content

Commit c120a32

Browse files
committed
Catch missing errors
1 parent 9baff8d commit c120a32

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Sources/ParseSwift/LiveQuery/LiveQuerySocket.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ extension LiveQuerySocket {
5353
.encode(StandardMessage(operation: .connect,
5454
additionalProperties: true))
5555
guard let encodedAsString = String(data: encoded, encoding: .utf8) else {
56+
let error = ParseError(code: .unknownError,
57+
message: "Couldn't encode connect message: \(encoded)")
58+
completion(error)
5659
return
5760
}
5861
task.send(.string(encodedAsString)) { error in

Sources/ParseSwift/LiveQuery/ParseLiveQuery.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,17 +502,25 @@ extension ParseLiveQuery {
502502
return
503503
}
504504
if isSocketEstablished {
505-
try? URLSession.liveQuery.connect(task: self.task) { error in
506-
if error == nil {
507-
self.isConnecting = true
505+
do {
506+
try URLSession.liveQuery.connect(task: self.task) { error in
507+
if error == nil {
508+
self.isConnecting = true
509+
}
508510
}
511+
completion(nil)
512+
} catch {
513+
completion(error)
509514
}
510515
} else {
511516
self.synchronizationQueue
512517
.asyncAfter(deadline: .now() + DispatchTimeInterval
513518
.seconds(reconnectInterval)) {
514519
self.createTask()
515520
self.attempts += 1
521+
let error = ParseError(code: .unknownError,
522+
message: "Attempted to open socket \(self.attempts)")
523+
completion(error)
516524
}
517525
}
518526
}

0 commit comments

Comments
 (0)