修复了异常的toast
This commit is contained in:
@@ -86,7 +86,7 @@ UIKIT_EXTERN NSString * adImageName;
|
||||
|
||||
#ifdef DEBUG
|
||||
config.debugMode = YES; // debug 模式下,开启调试模式
|
||||
config.reportLogLevel = BuglyLogLevelVerbose; // 设置打印日志级别
|
||||
config.reportLogLevel = BuglyLogLevelWarn; // 设置自定义日志上报的级别,默认不上报自定义日志
|
||||
[Bugly startWithAppId:KeyWithType(KeyTyoe_BuglyKey) config:config];
|
||||
#else
|
||||
config.debugMode = NO; // release 模式下,关闭调试模式
|
||||
|
@@ -21,7 +21,6 @@
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
manager = [[AFHTTPSessionManager manager]initWithBaseURL:[NSURL URLWithString:API_HOST_URL]];
|
||||
manager.requestSerializer.timeoutInterval = 15;
|
||||
manager.responseSerializer = [AFJSONResponseSerializer serializer];
|
||||
manager.requestSerializer.HTTPShouldHandleCookies = YES;
|
||||
// 客户端是否信任非法证书
|
||||
@@ -31,6 +30,7 @@
|
||||
// 是否在证书域字段中验证域名
|
||||
[manager.securityPolicy setValidatesDomainName:NO];
|
||||
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"text/plain",@"image/jpeg",@"image/png", nil];
|
||||
manager.requestSerializer.timeoutInterval = 40;
|
||||
});
|
||||
return manager;
|
||||
}
|
||||
@@ -43,6 +43,8 @@
|
||||
if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == 0) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
failure(-1, @"请检查网络连接。");
|
||||
NSException * extrion= [NSException exceptionWithName:method reason:@"接口没有网络" userInfo:nil];
|
||||
[Bugly reportException:extrion];
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -73,6 +75,8 @@
|
||||
if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == 0) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
failure(-1, @"请检查网络连接。");
|
||||
NSException * extrion= [NSException exceptionWithName:method reason:@"接口没有网络" userInfo:nil];
|
||||
[Bugly reportException:extrion];
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -122,8 +126,6 @@
|
||||
NSLog(@"\n%@", [baseModel toJSONString]);
|
||||
#endif
|
||||
success(baseModel);
|
||||
NSException * extrion= [NSException exceptionWithName:method reason:@"接口没有网络" userInfo:nil];
|
||||
[Bugly reportException:extrion];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[self handleNetError:error method:method failure:failure];
|
||||
}];
|
||||
@@ -219,7 +221,9 @@
|
||||
} else {
|
||||
if (error.code == -1009) {
|
||||
failure(error.code, @"网络异常,请检查网络后重试。");
|
||||
} else {
|
||||
} else if (error.code == -1001) {
|
||||
failure(error.code, @"请求超时,请稍后再试。");
|
||||
} else {
|
||||
failure(error.code, @"服务器正忙,请稍后重试。");
|
||||
}
|
||||
NSString * code = error.code ? [NSString stringWithFormat:@"%ld", error.code] : @"9999";
|
||||
|
Reference in New Issue
Block a user