Skip to content

Commit

Permalink
do not throw error in deletedocuments if id == nil, case-iterable status
Browse files Browse the repository at this point in the history
  • Loading branch information
phisakel committed Sep 2, 2024
1 parent 6d1ceb2 commit 3e3900f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/WalletStorage/Enumerations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public enum PrivateKeyType: String {


/// document status
public enum DocumentStatus: String {
public enum DocumentStatus: String, CaseIterable {
case issued
case deferred
case pending
Expand Down
5 changes: 4 additions & 1 deletion Sources/WalletStorage/KeyChainStorageService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ public class KeyChainStorageService: DataStorageService {
let query: [String: Any] = makeQuery(id: id, bForSave: true, status: docStatus, dataType: dataType)
let status = SecItemDelete(query as CFDictionary)
let statusMessage = SecCopyErrorMessageString(status, nil) as? String
guard status == errSecSuccess else {
if status == errSecItemNotFound, id == nil {
let msg = statusMessage ?? "No items found"
logger.warning("\(msg)")
} else if status != errSecSuccess {
logger.error("Error code: \(Int(status)), description: \(statusMessage ?? "")")
throw StorageError(description: statusMessage ?? "", code: Int(status))
}
Expand Down

0 comments on commit 3e3900f

Please sign in to comment.