From 3c852818eb0f84364f69eeaa5b8b8c3dd3d86ca0 Mon Sep 17 00:00:00 2001 From: PW Date: Fri, 2 Feb 2024 15:16:31 +0100 Subject: [PATCH] fix cancelation before continuation --- Sources/SwiftLocation/Async Tasks/SingleUpdateLocation.swift | 1 + Sources/SwiftLocation/Support/LocationErrors.swift | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Sources/SwiftLocation/Async Tasks/SingleUpdateLocation.swift b/Sources/SwiftLocation/Async Tasks/SingleUpdateLocation.swift index c9ef34b..777f2c2 100644 --- a/Sources/SwiftLocation/Async Tasks/SingleUpdateLocation.swift +++ b/Sources/SwiftLocation/Async Tasks/SingleUpdateLocation.swift @@ -87,6 +87,7 @@ extension Tasks { } public func didCancelled() { + continuation?.resume(throwing: LocationErrors.cancelled) continuation = nil } diff --git a/Sources/SwiftLocation/Support/LocationErrors.swift b/Sources/SwiftLocation/Support/LocationErrors.swift index 9fa2cc9..8ab1ec8 100644 --- a/Sources/SwiftLocation/Support/LocationErrors.swift +++ b/Sources/SwiftLocation/Support/LocationErrors.swift @@ -43,6 +43,9 @@ enum LocationErrors: LocalizedError { /// Operation timeout. case timeout + /// Cancelled before operation could complete. + case cancelled + var errorDescription: String? { switch self { case .plistNotConfigured: @@ -55,6 +58,8 @@ enum LocationErrors: LocalizedError { return "Not Authorized" case .timeout: return "Timeout" + case .cancelled: + return "Cancelled" } }