Skip to content

Commit 05819ac

Browse files
authored
Add check to address 8210 review (#8214)
* Add check to address 8210 review * NULL not nil
1 parent ec7c826 commit 05819ac

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

FirebaseAuth/Sources/AuthProvider/Phone/FIRPhoneAuthProvider.m

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -263,26 +263,28 @@ - (nullable NSString *)reCAPTCHATokenForURL:(NSURL *)URL error:(NSError **_Nonnu
263263
} else {
264264
errorData = nil;
265265
}
266-
NSError *jsonError;
267-
NSDictionary *errorDict = [NSJSONSerialization JSONObjectWithData:errorData
268-
options:0
269-
error:&jsonError];
270-
if (jsonError) {
271-
*error = [FIRAuthErrorUtils JSONSerializationErrorWithUnderlyingError:jsonError];
272-
return nil;
273-
}
274-
*error = [FIRAuthErrorUtils URLResponseErrorWithCode:errorDict[@"code"]
275-
message:errorDict[@"message"]];
276-
if (!*error) {
277-
NSString *reason;
278-
if (errorDict[@"code"] && errorDict[@"message"]) {
279-
reason = [NSString stringWithFormat:@"[%@] - %@", errorDict[@"code"], errorDict[@"message"]];
280-
} else {
281-
reason = [NSString stringWithFormat:@"An unknown error occurred with the following "
282-
"response: %@",
283-
deepLinkURL];
266+
if (error != NULL) {
267+
NSError *jsonError;
268+
NSDictionary *errorDict = [NSJSONSerialization JSONObjectWithData:errorData
269+
options:0
270+
error:&jsonError];
271+
if (jsonError) {
272+
*error = [FIRAuthErrorUtils JSONSerializationErrorWithUnderlyingError:jsonError];
273+
return nil;
274+
}
275+
*error = [FIRAuthErrorUtils URLResponseErrorWithCode:errorDict[@"code"]
276+
message:errorDict[@"message"]];
277+
if (!*error) {
278+
NSString *reason;
279+
if (errorDict[@"code"] && errorDict[@"message"]) {
280+
reason = [NSString stringWithFormat:@"[%@] - %@", errorDict[@"code"], errorDict[@"message"]];
281+
} else {
282+
reason = [NSString stringWithFormat:@"An unknown error occurred with the following "
283+
"response: %@",
284+
deepLinkURL];
285+
}
286+
*error = [FIRAuthErrorUtils appVerificationUserInteractionFailureWithReason:reason];
284287
}
285-
*error = [FIRAuthErrorUtils appVerificationUserInteractionFailureWithReason:reason];
286288
}
287289
return nil;
288290
}

0 commit comments

Comments
 (0)