Skip to content

Commit 91dffba

Browse files
refactor: remove GoogleServiceError
1 parent 66bc390 commit 91dffba

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/AuthServiceError.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public enum AuthServiceError: LocalizedError {
3636
case invalidCredentials(String)
3737
case signInFailed(underlying: Error)
3838
case accountMergeConflict(context: AccountMergeConflictContext)
39-
case invalidPhoneAuthenticationArguments(String)
4039
case providerNotFound(String)
4140
case multiFactorAuth(String)
4241

@@ -54,16 +53,20 @@ public enum AuthServiceError: LocalizedError {
5453
return description
5554
case let .invalidCredentials(description):
5655
return description
56+
// Use when failed to sign-in with Firebase
5757
case let .signInFailed(underlying: error):
5858
return "Failed to sign in: \(error.localizedDescription)"
59+
// Use when failed to sign-in with provider (e.g. Google, Facebook, etc.)
60+
case let .providerAuthenticationFailed(description):
61+
return description
5962
case let .accountMergeConflict(context):
6063
return context.errorDescription
6164
case let .providerNotFound(description):
6265
return description
63-
case let .invalidPhoneAuthenticationArguments(description):
64-
return description
6566
case let .multiFactorAuth(description):
6667
return description
68+
case let .rootViewControllerNotFound(description):
69+
return description
6770
}
6871
}
6972
}

FirebaseSwiftUI/FirebaseGoogleSwiftUI/Sources/Services/GoogleProviderAuthUI.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ import GoogleSignIn
1919
import GoogleSignInSwift
2020
import SwiftUI
2121

22-
public enum GoogleProviderError: Error {
23-
case rootViewControllerNotFound(String)
24-
case authenticationToken(String)
25-
case user(String)
26-
}
27-
2822
public class GoogleProviderSwift: AuthProviderSwift, DeleteUserSwift {
2923
let scopes: [String]
3024
let clientID: String
@@ -42,7 +36,7 @@ public class GoogleProviderSwift: AuthProviderSwift, DeleteUserSwift {
4236
@MainActor public func createAuthCredential() async throws -> AuthCredential {
4337
guard let presentingViewController = await (UIApplication.shared.connectedScenes
4438
.first as? UIWindowScene)?.windows.first?.rootViewController else {
45-
throw GoogleProviderError
39+
throw AuthServiceError
4640
.rootViewControllerNotFound(
4741
"Root View controller is not available to present Google sign-in View."
4842
)
@@ -63,7 +57,8 @@ public class GoogleProviderSwift: AuthProviderSwift, DeleteUserSwift {
6357
guard let user = result?.user,
6458
let idToken = user.idToken?.tokenString else {
6559
continuation
66-
.resume(throwing: GoogleProviderError.user("Failed to retrieve user or idToken."))
60+
.resume(throwing: AuthServiceError
61+
.providerAuthenticationFailed("Failed to retrieve user or idToken."))
6762
return
6863
}
6964

FirebaseSwiftUI/FirebasePhoneAuthSwiftUI/Sources/Services/PhoneAuthProviderAuthUI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class PhoneProviderSwift: PhoneAuthProviderSwift {
3939
guard let presentingViewController = await (UIApplication.shared.connectedScenes
4040
.first as? UIWindowScene)?.windows.first?.rootViewController else {
4141
throw AuthServiceError
42-
.invalidPhoneAuthenticationArguments(
42+
.rootViewControllerNotFound(
4343
"Root View controller is not available to present Phone auth View."
4444
)
4545
}

0 commit comments

Comments
 (0)