-
Notifications
You must be signed in to change notification settings - Fork 363
Expand file tree
/
Copy pathKeychainError.swift
More file actions
42 lines (34 loc) · 1.05 KB
/
KeychainError.swift
File metadata and controls
42 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// KeychainError.swift
// KeychainSwift
//
// Created by Lennard Sprong on 20/02/2025.
//
import Foundation
import Security
public struct KeychainError : RawRepresentable, CustomStringConvertible {
public init(rawValue: OSStatus) {
self.rawValue = rawValue
}
public init(_ code: OSStatus) {
rawValue = code
}
/// The result code for the operation.
public let rawValue: OSStatus
/// Retrieve the localized description for this error. This uses ``/Security/SecCopyErrorMessageString(_:_:)`` internally.
public var localizedDescription: String {
if let message = SecCopyErrorMessageString(rawValue, nil) {
return message as String
}
return description
}
public var description: String {
"KeychainError(\(rawValue))"
}
}
extension KeychainError : CustomNSError {
public static var errorDomain: String { NSOSStatusErrorDomain }
}
extension KeychainError : LocalizedError {
public var errorDescription: String? { localizedDescription }
}