Skip to content

FIS - make server error logs more readable #5654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ + (FIRInstallationsErrorCode)errorCodeWithHTTPCode:(NSInteger)HTTPCode {
+ (NSDictionary *)userInfoWithHTTPResponse:(NSHTTPURLResponse *)HTTPResponse
data:(nullable NSData *)data {
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *failureReason = [NSString
stringWithFormat:@"The server responded with an error. HTTP response: %@\nResponse body: %@",
HTTPResponse, responseString];
NSString *failureReason =
[NSString stringWithFormat:@"The server responded with an error: \n - URL: %@ \n - HTTP "
@"status code: %ld \n - Response body: %@",
HTTPResponse.URL, (long)HTTPResponse.statusCode, responseString];
return @{NSLocalizedFailureReasonErrorKey : failureReason};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ - (FIRInstallationsItem *)createInstallationWithFID:(NSString *)FID
if ([self doesRegistrationErrorRequireConfigChange:error]) {
FIRLogError(kFIRLoggerInstallations,
kFIRInstallationsMessageCodeInvalidFirebaseConfiguration,
@"Firebase Installation registration failed for app with name: %@, error: "
@"Firebase Installation registration failed for app with name: %@, error:\n"
@"%@\nPlease make sure you use valid GoogleService-Info.plist",
self.appName, error);
self.appName, error.userInfo[NSLocalizedFailureReasonErrorKey]);
}
})
.then(^id(FIRInstallationsItem *registeredInstallation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ - (void)testUserInfoContainsResponseData {
XCTAssertTrue([failureReason containsString:HTTPResponse.URL.absoluteString]);
XCTAssertTrue([failureReason containsString:@(HTTPResponse.statusCode).stringValue]);
XCTAssertTrue([failureReason containsString:@(HTTPResponse.statusCode).stringValue]);
XCTAssertTrue([failureReason containsString:@"header1"]);
XCTAssertTrue([failureReason containsString:@"value1"]);

// Validate response data content.
XCTAssertTrue([failureReason containsString:@"invalid request"]);
Expand Down