diff --git a/Mastodon/Protocol/Provider/DataSourceFacade+Follow.swift b/Mastodon/Protocol/Provider/DataSourceFacade+Follow.swift index f073b8939..cfb3ffea5 100644 --- a/Mastodon/Protocol/Provider/DataSourceFacade+Follow.swift +++ b/Mastodon/Protocol/Provider/DataSourceFacade+Follow.swift @@ -56,7 +56,7 @@ extension DataSourceFacade { continuation.resume(returning: relationship) } else { - continuation.resume(throwing: AppError.unexpected) + continuation.resume(throwing: AppError.unexpected()) } } alert.addAction(cancel) diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift index 2c9bb0e88..a1d73a92e 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift @@ -315,13 +315,16 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte authenticationBox: authenticationBox ).value - guard let entity = poll.status?.entity else { return } + guard let entity = poll.status?.entity else { throw AppError.unexpected("Poll vote recorded but could not be updated in view") } let newStatus: MastodonStatus = .fromEntity(entity) newStatus.poll = MastodonPoll(poll: newPoll, status: newStatus) self.update(status: newStatus, intent: .pollVote) } catch { + let alert = UIAlertController(title: "Poll Error", message: "Something went wrong while processing your response: \(error)", preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "OK", style: .cancel)) + self.sceneCoordinator?.tabBarController.showAlert(alert) statusView.viewModel.isVoting = false } diff --git a/MastodonSDK/Sources/MastodonCore/AppError.swift b/MastodonSDK/Sources/MastodonCore/AppError.swift index a46b4c719..518ec7db0 100644 --- a/MastodonSDK/Sources/MastodonCore/AppError.swift +++ b/MastodonSDK/Sources/MastodonCore/AppError.swift @@ -10,5 +10,5 @@ import Foundation public enum AppError: Error { case badRequest case badAuthentication - case unexpected + case unexpected(String? = nil) }