diff --git a/Delta/Launch/LaunchViewController.swift b/Delta/Launch/LaunchViewController.swift index 03262f5..58204e7 100644 --- a/Delta/Launch/LaunchViewController.swift +++ b/Delta/Launch/LaunchViewController.swift @@ -9,6 +9,8 @@ import UIKit import Roxas +import Harmony + class LaunchViewController: RSTLaunchViewController { @IBOutlet private var gameViewContainerView: UIView! @@ -75,11 +77,23 @@ extension LaunchViewController override func handleLaunchError(_ error: Error) { - let alertController = UIAlertController(title: NSLocalizedString("Unable to Launch Delta", comment: ""), message: error.localizedDescription, preferredStyle: .alert) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Retry", comment: ""), style: .default, handler: { (action) in + do + { + throw error + } + catch is HarmonyError + { + // Ignore self.handleLaunchConditions() - })) - self.present(alertController, animated: true, completion: nil) + } + catch + { + let alertController = UIAlertController(title: NSLocalizedString("Unable to Launch Delta", comment: ""), message: error.localizedDescription, preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: NSLocalizedString("Retry", comment: ""), style: .default, handler: { (action) in + self.handleLaunchConditions() + })) + self.present(alertController, animated: true, completion: nil) + } } override func finishLaunching() diff --git a/Delta/Syncing/SyncManager.swift b/Delta/Syncing/SyncManager.swift index 79e8b31..cf527ed 100644 --- a/Delta/Syncing/SyncManager.swift +++ b/Delta/Syncing/SyncManager.swift @@ -124,11 +124,39 @@ extension SyncManager _ = try result.get() self.coordinator = coordinator - completionHandler(.success) } + catch let authError as AuthenticationError + { + // Authentication failed, but otherwise started successfully so still assign self.coordinator. + self.coordinator = coordinator + + switch authError + { + case .other(ServiceError.connectionFailed): + // Authentication failed due to network connection, but otherwise started successfully so we ignore this error. + completionHandler(.success) + + default: + // Another authentication error occured, so we'll deauthenticate ourselves. + print("SyncManager.start auth error:", authError) + + self.deauthenticate() { (result) in + switch result + { + case .success: + completionHandler(.success) + + case .failure: + // authError is more useful than result's error. + completionHandler(.failure(authError)) + } + } + } + } catch { + print("SyncManager.start error:", error) completionHandler(.failure(error)) } }