import Foundation enum PlaybackError: Equatable, Sendable { case connectionTimeout case stationOffline case httpError(Int) case codecNotSupported case streamInterrupted case dnsResolutionFailed case unknown(String) var title: String { switch self { case .connectionTimeout: String(localized: "Connection timed out") case .stationOffline: String(localized: "Station is offline") case .httpError: String(localized: "Server error") case .codecNotSupported: String(localized: "Codec not supported") case .streamInterrupted: String(localized: "Stream interrupted") case .dnsResolutionFailed: String(localized: "Could not resolve host") case .unknown: String(localized: "Playback failed") } } var detail: String { switch self { case .connectionTimeout: String(localized: "The station did not respond in time. It may be overloaded or temporarily unavailable.") case .stationOffline: String(localized: "The stream URL is no longer available. The station may have shut down or changed its address.") case let .httpError(code): String(localized: "The server responded with HTTP \(code). The stream may be temporarily unavailable.") case .codecNotSupported: String(localized: "macOS cannot decode this stream format. Try a different station.") case .streamInterrupted: String(localized: "The connection was lost. The station may have ended the broadcast.") case .dnsResolutionFailed: String(localized: "The stream server address could not be found. Check your internet connection.") case let .unknown(message): message } } var isRetryable: Bool { switch self { case .connectionTimeout, .stationOffline, .httpError, .streamInterrupted: true case .codecNotSupported, .dnsResolutionFailed, .unknown: false } } }