Skip to content

Instantly share code, notes, and snippets.

@brennanMKE
Last active October 26, 2022 10:19
Show Gist options
  • Save brennanMKE/c0c0a049e42498385a459928f557e102 to your computer and use it in GitHub Desktop.
Save brennanMKE/c0c0a049e42498385a459928f557e102 to your computer and use it in GitHub Desktop.
Print Keychain Result Code which is an OSStatus used with various services such as Keychain
// MARK: - Internal -
internal func printResultCode(resultCode: OSStatus) {
// See: https://www.osstatus.com/
switch resultCode {
case errSecSuccess:
print("Keychain Status: No error.")
case errSecUnimplemented:
print("Keychain Status: Function or operation not implemented.")
case errSecIO:
print("Keychain Status: I/O error (bummers)")
case errSecOpWr:
print("Keychain Status: File already open with with write permission")
case errSecParam:
print("Keychain Status: One or more parameters passed to a function where not valid.")
case errSecAllocate:
print("Keychain Status: Failed to allocate memory.")
case errSecUserCanceled:
print("Keychain Status: User canceled the operation.")
case errSecBadReq:
print("Keychain Status: Bad parameter or invalid state for operation.")
case errSecInternalComponent:
print("Keychain Status: Internal Component")
case errSecNotAvailable:
print("Keychain Status: No keychain is available. You may need to restart your computer.")
case errSecDuplicateItem:
print("Keychain Status: The specified item already exists in the keychain.")
case errSecItemNotFound:
print("Keychain Status: The specified item could not be found in the keychain.")
case errSecInteractionNotAllowed:
print("Keychain Status: User interaction is not allowed.")
case errSecDecode:
print("Keychain Status: Unable to decode the provided data.")
case errSecAuthFailed:
print("Keychain Status: The user name or passphrase you entered is not correct.")
default:
print("Keychain Status: Unknown. (\(resultCode))")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment