Skip to content

Commit

Permalink
Merge pull request #103 from tidal-music/ekononenko/better-error-desc…
Browse files Browse the repository at this point in the history
…riptions-in-common-and-auth

Better error descriptions
  • Loading branch information
e-kononenko authored Sep 30, 2024
2 parents a865798 + 228c304 commit 2e91425
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Sources/Auth/Model/AuthLoggable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Sources/Common/TidalError.swift
Original file line number Diff line number Diff line change
@@ -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?
Expand All @@ -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))"
}
}

0 comments on commit 2e91425

Please sign in to comment.