mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
移除警告
This commit is contained in:
parent
adf0c1794e
commit
0bbfcb8781
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension String: Error {}
|
||||
extension String: @retroactive Error {}
|
||||
|
||||
public enum ApiError: Swift.Error {
|
||||
case Error(info: String)
|
||||
|
||||
@ -17,16 +17,14 @@ import UIKit
|
||||
extension Observable where Element: Moya.Response {
|
||||
/// 过滤 HTTP 错误,例如超时,请求失败等
|
||||
func filterHttpError() -> Observable<Result<Element, ApiError>> {
|
||||
return
|
||||
catchErrorJustReturn(Element(statusCode: 599, data: Data()))
|
||||
.map { response -> Result<Element, ApiError> in
|
||||
if (200 ... 209) ~= response.statusCode {
|
||||
return .success(response)
|
||||
}
|
||||
else {
|
||||
return .failure(ApiError.Error(info: "网络错误"))
|
||||
}
|
||||
return catchAndReturn(Element(statusCode: 599, data: Data()))
|
||||
.map { response -> Result<Element, ApiError> in
|
||||
if (200...209) ~= response.statusCode {
|
||||
return .success(response)
|
||||
} else {
|
||||
return .failure(ApiError.Error(info: "网络错误"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 过滤逻辑错误,例如协议里返回 错误CODE
|
||||
@ -43,16 +41,14 @@ extension Observable where Element: Moya.Response {
|
||||
code == 200
|
||||
{
|
||||
return .success(json)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var msg: String = ""
|
||||
if json["message"].exists() {
|
||||
msg = json["message"].rawString()!
|
||||
}
|
||||
return .failure(ApiError.Error(info: msg))
|
||||
}
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
return .failure(ApiError.Error(info: error.rawString()))
|
||||
}
|
||||
case .failure(let error):
|
||||
@ -76,8 +72,7 @@ extension Observable where Element: Moya.Response {
|
||||
}
|
||||
if let model: T = self.resultFromJSON(json: rootJson) {
|
||||
return .success(model)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return .failure(ApiError.Error(info: "json 转换失败"))
|
||||
}
|
||||
case .failure(let error):
|
||||
@ -103,8 +98,7 @@ extension Observable where Element: Moya.Response {
|
||||
for json in jsonArray {
|
||||
if let jsonModel: T = self.resultFromJSON(json: json) {
|
||||
result.append(jsonModel)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return .failure(ApiError.Error(info: "json 转换失败"))
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,8 +22,7 @@ class iCloudStatusCell: UITableViewCell {
|
||||
switch status {
|
||||
case .available:
|
||||
self.detailTextLabel?.text = NSLocalizedString("available")
|
||||
|
||||
case .noAccount, .restricted:
|
||||
case .noAccount, .restricted, .temporarilyUnavailable:
|
||||
self.detailTextLabel?.text = NSLocalizedString("restricted")
|
||||
case .couldNotDetermine:
|
||||
self.detailTextLabel?.text = NSLocalizedString("unknown")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user