添加了接口报错的上报
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "YYReachability.h"
|
||||
#import <AFNetworking.h>
|
||||
#import <Bugly/Bugly.h>
|
||||
|
||||
@implementation HttpRequestHelper
|
||||
|
||||
@@ -60,7 +61,7 @@
|
||||
#endif
|
||||
success(baseModel);
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[self handleNetError:error failure:failure];
|
||||
[self handleNetError:error method:method failure:failure];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@
|
||||
#endif
|
||||
success(baseModel);
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[self handleNetError:error failure:failure];
|
||||
[self handleNetError:error method:method failure:failure];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -102,6 +103,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;
|
||||
}
|
||||
@@ -119,8 +122,10 @@
|
||||
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 failure:failure];
|
||||
[self handleNetError:error method:method failure:failure];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -201,7 +206,7 @@
|
||||
return dic;
|
||||
}
|
||||
|
||||
+ (void)handleNetError:(NSError *)error
|
||||
+ (void)handleNetError:(NSError *)error method:(NSString *)method
|
||||
failure:(void (^)(NSInteger resCode, NSString *message))failure
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@@ -217,6 +222,12 @@
|
||||
} else {
|
||||
failure(error.code, @"服务器正忙,请稍后重试。");
|
||||
}
|
||||
NSString * code = error.code ? [NSString stringWithFormat:@"%ld", error.code] : @"9999";
|
||||
NSString * des = error.description.length > 0 ? error.description : @"接口报错信息未知";
|
||||
NSException *exception = [NSException exceptionWithName:@"229181"
|
||||
reason:method
|
||||
userInfo:@{@"code":code, @"desc":des}];
|
||||
[Bugly reportException:exception];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +307,7 @@
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
[self handleNetError:error failure:^(NSInteger resCode, NSString *message) {
|
||||
[self handleNetError:error method:path failure:^(NSInteger resCode, NSString *message) {
|
||||
completion(nil, resCode, message);
|
||||
}];
|
||||
}
|
||||
|
Reference in New Issue
Block a user