Skip to content

Commit

Permalink
Move internalCode check login into main switch
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorov-d committed Apr 25, 2024
1 parent a58f93f commit 8303991
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions TangemSdk/TangemSdk/Common/Core/TangemSdkError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,12 @@ public enum TangemSdkError: Error, LocalizedError, Encodable {
case .backupFailedAlreadyCreated:
return "error_backup_failed_already_created".localized
case .resetPinWrongCard(let internalCode):
return localizedMessageForResetPinWrongCard(code: internalCode)
switch internalCode {
case TangemSdkError.noActiveBackup.code:
return "error_no_active_backup".localized
default:
return "error_reset_wrong_card".localized("\(self.code)")
}
case .oldCard: return "error_old_card".localized
case .userCodeRecoveryDisabled: return "error_user_code_recovery_disabled".localized

Expand All @@ -530,15 +535,6 @@ public enum TangemSdkError: Error, LocalizedError, Encodable {
}
}

private func localizedMessageForResetPinWrongCard(code: Int?) -> String {
switch code {
case TangemSdkError.noActiveBackup.code:
return "error_no_active_backup".localized
default:
return "error_reset_wrong_card".localized("\(self.code)")
}
}

public var jsonDescription: String {
let encoder = JSONEncoder()
encoder.outputFormatting = [.sortedKeys, .prettyPrinted]
Expand Down

0 comments on commit 8303991

Please sign in to comment.