Skip to content

Commit 7ee5b63

Browse files
committed
fix(ios): include underlying authorization error causes
1 parent ac5f792 commit 7ee5b63

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

packages/react-native-app-auth/ios/RNAppAuth.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,14 +730,22 @@ - (NSString*)getErrorCode: (NSError*) error defaultCode: (NSString *) defaultCod
730730

731731
- (NSString*)getErrorMessage: (NSError*) error {
732732
NSDictionary * userInfo = [error userInfo];
733+
NSString *message;
733734

734735
if (userInfo &&
735736
userInfo[OIDOAuthErrorResponseErrorKey] &&
736737
userInfo[OIDOAuthErrorResponseErrorKey][OIDOAuthErrorFieldErrorDescription]) {
737-
return userInfo[OIDOAuthErrorResponseErrorKey][OIDOAuthErrorFieldErrorDescription];
738+
message = userInfo[OIDOAuthErrorResponseErrorKey][OIDOAuthErrorFieldErrorDescription];
738739
} else {
739-
return [error localizedDescription];
740+
message = [error localizedDescription];
740741
}
742+
743+
NSError *underlyingError = userInfo[NSUnderlyingErrorKey];
744+
if (underlyingError && [underlyingError isKindOfClass:[NSError class]] && [underlyingError localizedDescription]) {
745+
message = [message stringByAppendingFormat:@" - Cause: %@", [underlyingError localizedDescription]];
746+
}
747+
748+
return message;
741749
}
742750

743751
- (id<OIDExternalUserAgent>)getExternalUserAgentWithPresentingViewController: (UIViewController *)presentingViewController

0 commit comments

Comments
 (0)