From ee6039d7ee5ca0fbd862eeaafe8c5312a29d1bba Mon Sep 17 00:00:00 2001 From: Jens Utbult Date: Tue, 26 Nov 2024 09:55:24 +0100 Subject: [PATCH] Better error type thrown when device info is invalid. --- Authenticator/Model/OATHSession.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Authenticator/Model/OATHSession.swift b/Authenticator/Model/OATHSession.swift index 6481de32..e68b5718 100644 --- a/Authenticator/Model/OATHSession.swift +++ b/Authenticator/Model/OATHSession.swift @@ -21,6 +21,7 @@ enum OATHSessionError: Error, LocalizedError, Equatable { case credentialAlreadyPresent(YKFOATHCredentialTemplate) case otpEnabledError case connectionCancelled + case invalidDeviceInfo public var errorDescription: String? { switch self { @@ -30,6 +31,8 @@ enum OATHSessionError: Error, LocalizedError, Equatable { return String(localized: "Yubico OTP enabled", comment: "OATH otp enabled error message") case .connectionCancelled: return String(localized: "Connection cancelled by user", comment: "Internal error message not to be displayed to the user.") + case .invalidDeviceInfo: + return String(localized: "Invalid device info received from YubiKey", comment: "Internal error message not to be displayed to the user.") } } } @@ -160,7 +163,7 @@ class OATHSessionHandler: NSObject, YKFManagerDelegate { return } guard let configuration = deviceInfo.configuration else { - self.wiredContinuation?.resume(throwing: "Error!!!") + self.wiredContinuation?.resume(throwing: OATHSessionError.invalidDeviceInfo) self.wiredContinuation = nil self.wiredConnectionCallback = nil return