We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 74c338f commit 2f18c38Copy full SHA for 2f18c38
QiniuSDK/Http/QNResponseInfo.m
@@ -93,7 +93,12 @@ - (instancetype)init:(int)status
93
NSError *tmp;
94
NSDictionary *uInfo = [NSJSONSerialization JSONObjectWithData:body options:NSJSONReadingMutableLeaves error:&tmp];
95
if (tmp != nil) {
96
- uInfo = @{ @"error":[[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding] };
+ // 出现错误时,如果信息是非UTF8编码会失败,返回nil
97
+ NSString *str = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding];
98
+ if (str == nil) {
99
+ str = @"";
100
+ }
101
+ uInfo = @{ @"error": str };
102
}
103
_error = [[NSError alloc] initWithDomain:domain code:_statusCode userInfo:uInfo];
104
0 commit comments