Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
fix: 🐛 avoid "A server error occurred" msgs related to polling
Browse files Browse the repository at this point in the history
Polling request might time out if app goes into background. New polling
request will be started when app comes back into foreground. There is no
reason to bother the enduser with messages related to polling. Hence, in
this commit `PollMessageDelivery` will no longer emit error messages
related to polling.
  • Loading branch information
MarcoEidinger committed Jul 29, 2021
1 parent 2d3bed2 commit 942096a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Sources/SAPCAI/Foundation/Networking/PollMessageDelivery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public class PollMessageDelivery: MessageDelivering {

private var conversationId: String?

private var state: State = .stopped
private var state: State = .stopped {
didSet {
self.logger.debug("Polling \(state)")
}
}

private var logger = Logger.shared(named: "PollMessageDelivery")

Expand Down Expand Up @@ -100,16 +104,13 @@ public class PollMessageDelivery: MessageDelivering {
}

case .failure(let error):
self.logger.error(error.debugDescription, error: error)
switch error.type {
case .server:
self.logger.error(error.debugDescription, error: error)
self.onMessages?(.failure(error))
self.startPolling()
case .cancelled:
() // this naturally occurs when bot responses early?
()
case .dataDecoding, .conversationNotFound:
self.logger.error(error.debugDescription, error: error)
self.onMessages?(.failure(error))
self._stop()
}
}
Expand Down

0 comments on commit 942096a

Please sign in to comment.