From 228c3040d088cc57890429f859188ede6c6f76fe Mon Sep 17 00:00:00 2001 From: Evgenii Kononenko Date: Mon, 30 Sep 2024 17:51:21 +0200 Subject: [PATCH] TidalError, AuthLoggable: got rid of localized descriptions in favor of String(describing:) and CustomStringConvertible --- Sources/Auth/Model/AuthLoggable.swift | 6 +++--- Sources/Common/TidalError.swift | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Auth/Model/AuthLoggable.swift b/Sources/Auth/Model/AuthLoggable.swift index 06792e15..706bc4cb 100644 --- a/Sources/Auth/Model/AuthLoggable.swift +++ b/Sources/Auth/Model/AuthLoggable.swift @@ -65,15 +65,15 @@ extension AuthLoggable { let .finalizeLoginNetworkError(error), let .finalizeDeviceLoginNetworkError(error), let .getCredentialsUpgradeTokenNetworkError(error): - metadata[Self.metadataErrorKey] = "\(error.localizedDescription)" + metadata[Self.metadataErrorKey] = .string(.init(describing: error)) case let .getCredentialsRefreshTokenNetworkError(error, previousSubstatus), let .getCredentialsRefreshTokenWithClientCredentialsNetworkError(error, previousSubstatus): - metadata[Self.metadataErrorKey] = "\(error.localizedDescription)" + metadata[Self.metadataErrorKey] = .string(.init(describing: error)) metadata[Self.metadataPreviousSubstatusKey] = "\(previousSubstatus ?? "nil")" case let .authLogout(reason, error, previousSubstatus): metadata[Self.metadataReasonKey] = "\(reason)" if let error = error { - metadata[Self.metadataErrorKey] = "\(error.localizedDescription)" + metadata[Self.metadataErrorKey] = .string(.init(describing: error)) } metadata[Self.metadataPreviousSubstatusKey] = "\(previousSubstatus ?? "nil")" return metadata diff --git a/Sources/Common/TidalError.swift b/Sources/Common/TidalError.swift index 9cb137c5..ae7ba4ba 100644 --- a/Sources/Common/TidalError.swift +++ b/Sources/Common/TidalError.swift @@ -1,6 +1,6 @@ import Foundation -open class TidalError: LocalizedError { +open class TidalError: Error, CustomStringConvertible { public let code: String public let subStatus: Int? public let message: String? @@ -18,7 +18,7 @@ open class TidalError: LocalizedError { self.throwable = throwable } - public var errorDescription: String? { - "\(self), code: \(code), substatus: \(subStatus?.description ?? "nil"), message: \(message ?? "nil"), throwable: \(throwable.map { "\($0)" } ?? "nil"), throwable description: \(throwable?.localizedDescription ?? "nil")" + public var description: String { + "\(String(describing: type(of: self))), code: \(code), substatus: \(subStatus?.description ?? "nil"), message: \(message ?? "nil"), throwable: \(String(describing: throwable))" } }