31 lines
1.2 KiB
Swift
31 lines
1.2 KiB
Swift
import Foundation
|
|
|
|
enum FeishuError: Error, LocalizedError {
|
|
case unauthorized
|
|
case networkError(Error?)
|
|
case apiError(code: Int, message: String)
|
|
case decodingError(Error, rawBody: String? = nil)
|
|
case notConfigured
|
|
case missingCredentials
|
|
|
|
var errorDescription: String? {
|
|
switch self {
|
|
case .unauthorized:
|
|
return "Feishu authorization expired. Please re-authenticate."
|
|
case .networkError(let error):
|
|
return "Network error: \(error?.localizedDescription ?? "Unknown")"
|
|
case .apiError(let code, let message):
|
|
return "Feishu API error (\(code)): \(message)"
|
|
case .decodingError(let error, let rawBody):
|
|
if let rawBody {
|
|
return "Failed to parse Feishu response: \(rawBody)"
|
|
}
|
|
return "Failed to parse Feishu response. Field mappings may be incorrect. (\(error.localizedDescription))"
|
|
case .notConfigured:
|
|
return "Feishu table not configured. Open Settings."
|
|
case .missingCredentials:
|
|
return "Feishu app credentials are missing. Set FEISHU_APP_ID and FEISHU_APP_SECRET."
|
|
}
|
|
}
|
|
}
|