Skip to content

Commit

Permalink
Better error type thrown when device info is invalid.
Browse files Browse the repository at this point in the history
  • Loading branch information
jensutbult committed Nov 26, 2024
1 parent fbcd9d6 commit ee6039d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Authenticator/Model/OATHSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum OATHSessionError: Error, LocalizedError, Equatable {
case credentialAlreadyPresent(YKFOATHCredentialTemplate)
case otpEnabledError
case connectionCancelled
case invalidDeviceInfo

public var errorDescription: String? {
switch self {
Expand All @@ -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.")
}
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ee6039d

Please sign in to comment.