Skip to content

Commit 2f35a9d

Browse files
committed
Merge remote-tracking branch 'tc/FixInternalErrorGenerationBug' into pb-internal-error-fix
2 parents 3805752 + 89adc2a commit 2f35a9d

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

FirebaseFunctions/Sources/FunctionsError.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,18 @@ internal func FunctionsErrorForResponse(status: NSInteger,
225225
if let status = errorDetails["status"] as? String {
226226
code = FunctionsErrorCode.errorCode(forName: status)
227227

228+
if let message = errorDetails["message"] as? String {
229+
description = message
230+
} else {
231+
description = code.descriptionForErrorCode
232+
}
233+
228234
// If the code in the body is invalid, treat the whole response as malformed.
229235
guard code != .internal else {
230-
return code.generatedError(userInfo: nil)
236+
return code.generatedError(userInfo: [NSLocalizedDescriptionKey: description])
231237
}
232238
}
233239

234-
if let message = errorDetails["message"] as? String {
235-
description = message
236-
} else {
237-
description = code.descriptionForErrorCode
238-
}
239-
240240
details = errorDetails["details"] as AnyObject?
241241
if let innerDetails = details {
242242
// Just ignore the details if there an error decoding them.

FirebaseFunctions/Tests/Integration/IntegrationTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ class IntegrationTests: XCTestCase {
442442
} catch {
443443
let error = error as NSError
444444
XCTAssertEqual(FunctionsErrorCode.internal.rawValue, error.code)
445-
XCTAssertEqual("INTERNAL", error.localizedDescription)
445+
XCTAssertNotEqual("INTERNAL", error.localizedDescription)
446446
expectation.fulfill()
447447
return
448448
}
@@ -473,7 +473,7 @@ class IntegrationTests: XCTestCase {
473473
} catch {
474474
let error = error as NSError
475475
XCTAssertEqual(FunctionsErrorCode.internal.rawValue, error.code)
476-
XCTAssertEqual("INTERNAL", error.localizedDescription)
476+
XCTAssertNotEqual("INTERNAL", error.localizedDescription)
477477
}
478478
}
479479
}
@@ -498,7 +498,7 @@ class IntegrationTests: XCTestCase {
498498
} catch {
499499
let error = error as NSError
500500
XCTAssertEqual(FunctionsErrorCode.internal.rawValue, error.code)
501-
XCTAssertEqual("INTERNAL", error.localizedDescription)
501+
XCTAssertNotEqual("INTERNAL", error.localizedDescription)
502502
expectation.fulfill()
503503
return
504504
}
@@ -528,7 +528,7 @@ class IntegrationTests: XCTestCase {
528528
} catch {
529529
let error = error as NSError
530530
XCTAssertEqual(FunctionsErrorCode.internal.rawValue, error.code)
531-
XCTAssertEqual("INTERNAL", error.localizedDescription)
531+
XCTAssertNotEqual("INTERNAL", error.localizedDescription)
532532
}
533533
}
534534
}

FirebaseFunctions/Tests/ObjCIntegration/FIRIntegrationTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ - (void)testUnknownError {
226226
completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
227227
XCTAssertNotNil(error);
228228
XCTAssertEqual(FIRFunctionsErrorCodeInternal, error.code);
229-
XCTAssertEqualObjects(@"INTERNAL", error.localizedDescription);
229+
XCTAssertNotEqualObjects(@"INTERNAL", error.localizedDescription);
230230
[expectation fulfill];
231231
}];
232232
[self waitForExpectations:@[ expectation ] timeout:10];

0 commit comments

Comments
 (0)