001project_wildgrowth/ios/WildGrowth/WildGrowth/APIError.swift

26 lines
618 B
Swift

import Foundation
enum APIError: LocalizedError {
case invalidURL
case noData
case decodingError
case serverError(String)
case unauthorized
case unknown(Error)
var errorDescription: String? {
switch self {
case .invalidURL: return "无效的 URL"
case .noData: return "服务器未返回数据"
case .decodingError: return "数据解析失败"
case .serverError(let msg): return msg
case .unauthorized: return "登录已过期,请重新登录"
case .unknown(let error): return error.localizedDescription
}
}
}