import Foundation

enum WatchAPIError: Error, LocalizedError {
    case invalidURL
    case transport(Error)
    case http(Int, String?)
    case decode(Error)
    case noAuth

    var errorDescription: String? {
        switch self {
        case .invalidURL: return "Invalid URL"
        case .transport(let e): return e.localizedDescription
        case .http(let code, let body):
            if let body, !body.isEmpty { return "HTTP \(code): \(body)" }
            return "HTTP \(code)"
        case .decode(let e): return "Decode error: \(e.localizedDescription)"
        case .noAuth: return "Not signed in"
        }
    }
}
