mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-28 00:14:14 +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
|
||||
dictionaryWithObjectsAndKeys:symbolIdDictionary, @"symbol_id", type,
|
||||
@"symbol_upload_type", nil];
|
||||
NSError* error;
|
||||
NSError* error = nil;
|
||||
NSData* jsonData =
|
||||
[NSJSONSerialization dataWithJSONObject:jsonDictionary
|
||||
options:NSJSONWritingPrettyPrinted
|
||||
error:&error];
|
||||
if (error) {
|
||||
if (jsonData == nil) {
|
||||
fprintf(stdout, "Error: %s\n", [[error localizedDescription] UTF8String]);
|
||||
fprintf(stdout,
|
||||
"Failed to complete upload. Could not write JSON payload.\n");
|
||||
return CompleteUploadResultError;
|
||||
}
|
||||
|
||||
NSString* body = [[NSString alloc] initWithData:jsonData
|
||||
encoding:NSUTF8StringEncoding];
|
||||
|
||||
HTTPSimplePostRequest* postRequest =
|
||||
[[HTTPSimplePostRequest alloc] initWithURL:URL];
|
||||
[postRequest setBody:body];
|
||||
[postRequest setContentType:@"application/json"];
|
||||
|
||||
error = nil;
|
||||
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
|
||||
encoding:NSUTF8StringEncoding];
|
||||
int responseCode = [[postRequest response] statusCode];
|
||||
[postRequest release];
|
||||
|
||||
if (error || responseCode != 200) {
|
||||
if (responseCode != 200) {
|
||||
fprintf(stdout, "Failed to complete upload URL.\n");
|
||||
fprintf(stdout, "Response code: %d\n", responseCode);
|
||||
fprintf(stdout, "Response:\n");
|
||||
|
Loading…
Reference in New Issue
Block a user