in FBSDKCoreKit/FBSDKCoreKitTests/GraphRequestConnectionTests.swift [941:992]
func testErrorFromResultMessagePriority() {
var response: [String: Any] = [
"body": [
"error": ["error_msg": "error_msg"],
],
]
var error = connection.error(
fromResult: response,
request: makeSampleRequest()
) as? TestSDKError
XCTAssertEqual(
error?.message,
"error_msg",
"Should use the 'error_msg' if it's the only message available"
)
response = [
"body": [
"error": [
"error_msg": "error_msg",
"error_reason": "error_reason",
],
],
]
error = connection.error(
fromResult: response,
request: makeSampleRequest()
) as? TestSDKError
XCTAssertEqual(
error?.message,
"error_reason",
"Should prefer the 'error_reason' to the 'error_msg'"
)
response = [
"body": [
"error": [
"error_msg": "error_msg",
"error_reason": "error_reason",
"message": "message",
],
],
]
error = connection.error(
fromResult: response,
request: makeSampleRequest()
) as? TestSDKError
XCTAssertEqual(
error?.message,
"message",
"Should prefer the 'message' key to other error message keys"
)
}