mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-30 22:14:21 +01:00
Change JSON serialization error check.
- Mac OS symupload used to check for errors in JSON serialization by inspecting the "error" out parameter of the serialization function. Now it checks the returned data for "nil". - Similar change for the HTTP request that's made in the same function. Change-Id: I86f50ef44e60ee119c302e0614b115a8d35e9b5b Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2390753 Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
bdac77a801
commit
9c4671f2e3
@ -202,32 +202,37 @@
|
|||||||
NSDictionary* jsonDictionary = [NSDictionary
|
NSDictionary* jsonDictionary = [NSDictionary
|
||||||
dictionaryWithObjectsAndKeys:symbolIdDictionary, @"symbol_id", type,
|
dictionaryWithObjectsAndKeys:symbolIdDictionary, @"symbol_id", type,
|
||||||
@"symbol_upload_type", nil];
|
@"symbol_upload_type", nil];
|
||||||
NSError* error;
|
NSError* error = nil;
|
||||||
NSData* jsonData =
|
NSData* jsonData =
|
||||||
[NSJSONSerialization dataWithJSONObject:jsonDictionary
|
[NSJSONSerialization dataWithJSONObject:jsonDictionary
|
||||||
options:NSJSONWritingPrettyPrinted
|
options:NSJSONWritingPrettyPrinted
|
||||||
error:&error];
|
error:&error];
|
||||||
if (error) {
|
if (jsonData == nil) {
|
||||||
|
fprintf(stdout, "Error: %s\n", [[error localizedDescription] UTF8String]);
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
"Failed to complete upload. Could not write JSON payload.\n");
|
"Failed to complete upload. Could not write JSON payload.\n");
|
||||||
return CompleteUploadResultError;
|
return CompleteUploadResultError;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString* body = [[NSString alloc] initWithData:jsonData
|
NSString* body = [[NSString alloc] initWithData:jsonData
|
||||||
encoding:NSUTF8StringEncoding];
|
encoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
HTTPSimplePostRequest* postRequest =
|
HTTPSimplePostRequest* postRequest =
|
||||||
[[HTTPSimplePostRequest alloc] initWithURL:URL];
|
[[HTTPSimplePostRequest alloc] initWithURL:URL];
|
||||||
[postRequest setBody:body];
|
[postRequest setBody:body];
|
||||||
[postRequest setContentType:@"application/json"];
|
[postRequest setContentType:@"application/json"];
|
||||||
|
|
||||||
error = nil;
|
|
||||||
NSData* data = [postRequest send:&error];
|
NSData* data = [postRequest send:&error];
|
||||||
|
if (data == nil) {
|
||||||
|
fprintf(stdout, "Error: %s\n", [[error localizedDescription] UTF8String]);
|
||||||
|
fprintf(stdout, "Failed to complete upload URL.\n");
|
||||||
|
return CompleteUploadResultError;
|
||||||
|
}
|
||||||
|
|
||||||
NSString* result = [[NSString alloc] initWithData:data
|
NSString* result = [[NSString alloc] initWithData:data
|
||||||
encoding:NSUTF8StringEncoding];
|
encoding:NSUTF8StringEncoding];
|
||||||
int responseCode = [[postRequest response] statusCode];
|
int responseCode = [[postRequest response] statusCode];
|
||||||
[postRequest release];
|
[postRequest release];
|
||||||
|
if (responseCode != 200) {
|
||||||
if (error || responseCode != 200) {
|
|
||||||
fprintf(stdout, "Failed to complete upload URL.\n");
|
fprintf(stdout, "Failed to complete upload URL.\n");
|
||||||
fprintf(stdout, "Response code: %d\n", responseCode);
|
fprintf(stdout, "Response code: %d\n", responseCode);
|
||||||
fprintf(stdout, "Response:\n");
|
fprintf(stdout, "Response:\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user