Skip to content

Commit e5a1360

Browse files
FIS - make server error logs more readable (#5654)
* FIS - make server error logs more readable * Changelog
1 parent 349608b commit e5a1360

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

FirebaseInstallations/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- [changed] Mac OS Keychain storage changes: use a unique (per app) Keychain Service name to isolate Keychain items for different Mac OS applications.
44
NOTE: Installation Identifiers created by previous versions will be reset on Mac OS which can affect e.g. A/B Testing variants or debug device targeting for Firebase Messaging.
55
iOS, TVOS and watchOS Installation Identifiers will not be affected. (#5603)
6+
- [changed] More readable server error console messages. (#5654)
67

78
# v1.2.0 -- M69
89

FirebaseInstallations/Source/Library/Errors/FIRInstallationsHTTPError.m

+4-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ + (FIRInstallationsErrorCode)errorCodeWithHTTPCode:(NSInteger)HTTPCode {
4141
+ (NSDictionary *)userInfoWithHTTPResponse:(NSHTTPURLResponse *)HTTPResponse
4242
data:(nullable NSData *)data {
4343
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
44-
NSString *failureReason = [NSString
45-
stringWithFormat:@"The server responded with an error. HTTP response: %@\nResponse body: %@",
46-
HTTPResponse, responseString];
44+
NSString *failureReason =
45+
[NSString stringWithFormat:@"The server responded with an error: \n - URL: %@ \n - HTTP "
46+
@"status code: %ld \n - Response body: %@",
47+
HTTPResponse.URL, (long)HTTPResponse.statusCode, responseString];
4748
return @{NSLocalizedFailureReasonErrorKey : failureReason};
4849
}
4950

FirebaseInstallations/Source/Library/InstallationsIDController/FIRInstallationsIDController.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ - (FIRInstallationsItem *)createInstallationWithFID:(NSString *)FID
258258
if ([self doesRegistrationErrorRequireConfigChange:error]) {
259259
FIRLogError(kFIRLoggerInstallations,
260260
kFIRInstallationsMessageCodeInvalidFirebaseConfiguration,
261-
@"Firebase Installation registration failed for app with name: %@, error: "
261+
@"Firebase Installation registration failed for app with name: %@, error:\n"
262262
@"%@\nPlease make sure you use valid GoogleService-Info.plist",
263-
self.appName, error);
263+
self.appName, error.userInfo[NSLocalizedFailureReasonErrorKey]);
264264
}
265265
})
266266
.then(^id(FIRInstallationsItem *registeredInstallation) {

FirebaseInstallations/Source/Tests/Unit/FIRInstallationsHTTPErrorTests.m

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ - (void)testUserInfoContainsResponseData {
4848
XCTAssertTrue([failureReason containsString:HTTPResponse.URL.absoluteString]);
4949
XCTAssertTrue([failureReason containsString:@(HTTPResponse.statusCode).stringValue]);
5050
XCTAssertTrue([failureReason containsString:@(HTTPResponse.statusCode).stringValue]);
51-
XCTAssertTrue([failureReason containsString:@"header1"]);
52-
XCTAssertTrue([failureReason containsString:@"value1"]);
5351

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

0 commit comments

Comments
 (0)