Skip to content

Commit 89f237a

Browse files
authored
Swift first exception messages (#8295)
* Swift first exception messages * Review * Minor edit * Minor edit 2
1 parent 3cd7437 commit 89f237a

File tree

5 files changed

+30
-24
lines changed

5 files changed

+30
-24
lines changed

FirebaseAppCheck/Sources/Core/FIRAppCheck.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ + (instancetype)appCheck {
174174
if (!defaultApp) {
175175
[NSException raise:FIRAppCheckErrorDomain
176176
format:@"The default FirebaseApp instance must be configured before the default"
177-
@"AppCheck instance can be initialized. One way to ensure that is to "
178-
@"call `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) in the App"
179-
@" Delegate's `application:didFinishLaunchingWithOptions:` "
180-
@"(`application(_:didFinishLaunchingWithOptions:)` in Swift)."];
177+
@"AppCheck instance can be initialized. One way to ensure this is to "
178+
@"call `FirebaseApp.configure()` in the App Delegate's "
179+
@"`application(_:didFinishLaunchingWithOptions:)` (or the `@main` struct's "
180+
@"initializer in SwiftUI)."];
181181
}
182182
return [self appCheckWithApp:defaultApp];
183183
}

FirebaseAuth/Sources/Auth/FIRAuth.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,13 @@ + (void)initialize {
433433
+ (FIRAuth *)auth {
434434
FIRApp *defaultApp = [FIRApp defaultApp];
435435
if (!defaultApp) {
436-
[NSException raise:NSInternalInconsistencyException
437-
format:@"The default FIRApp instance must be configured before the default FIRAuth"
438-
@"instance can be initialized. One way to ensure that is to call "
439-
@"`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) in the App "
440-
@"Delegate's `application:didFinishLaunchingWithOptions:` "
441-
@"(`application(_:didFinishLaunchingWithOptions:)` in Swift)."];
436+
[NSException
437+
raise:NSInternalInconsistencyException
438+
format:@"The default FirebaseApp instance must be configured before the default Auth"
439+
@"instance can be initialized. One way to ensure this is to call "
440+
@"`FirebaseApp.configure()` in the App Delegate's "
441+
@"`application(_:didFinishLaunchingWithOptions:)` (or the `@main` struct's "
442+
@"initializer in SwiftUI)."];
442443
}
443444
return [self authWithApp:defaultApp];
444445
}
@@ -1393,7 +1394,7 @@ - (void)removeAuthStateDidChangeListener:(FIRAuthStateDidChangeListenerHandle)li
13931394
- (FIRIDTokenDidChangeListenerHandle)addIDTokenDidChangeListener:
13941395
(FIRIDTokenDidChangeListenerBlock)listener {
13951396
if (!listener) {
1396-
[NSException raise:NSInvalidArgumentException format:@"listener must not be nil."];
1397+
[NSException raise:NSInvalidArgumentException format:@"Listener must not be nil."];
13971398
return nil;
13981399
}
13991400
FIRAuthStateDidChangeListenerHandle handle;

FirebaseCore/Sources/FIRApp.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ + (void)configure {
129129
FIROptions *options = [FIROptions defaultOptions];
130130
if (!options) {
131131
[NSException raise:kFirebaseCoreErrorDomain
132-
format:@"`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find "
132+
format:@"`FirebaseApp.configure()` could not find "
133133
@"a valid GoogleService-Info.plist in your project. Please download one "
134134
@"from %@.",
135135
kPlistURL];
@@ -250,8 +250,11 @@ + (FIRApp *)defaultApp {
250250
}
251251
FIRLogError(kFIRLoggerCore, @"I-COR000003",
252252
@"The default Firebase app has not yet been "
253-
@"configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your "
254-
@"application initialization. Read more: https://goo.gl/ctyzm8.");
253+
@"configured. Add `FirebaseApp.configure()` to your "
254+
@"application initialization. This can be done in "
255+
@"in the App Delegate's application(_:didFinishLaunchingWithOptions:)` "
256+
@"(or the `@main` struct's initializer in SwiftUI). "
257+
@"Read more: https://goo.gl/ctyzm8.");
255258
return nil;
256259
}
257260

FirebaseDatabase/Sources/Api/FIRDatabase.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ @implementation FIRDatabase
3232

3333
+ (FIRDatabase *)database {
3434
if (![FIRApp isDefaultAppConfigured]) {
35-
[NSException raise:@"FIRAppNotConfigured"
36-
format:@"Failed to get default Firebase Database instance. "
37-
@"Must call `[FIRApp "
38-
@"configure]` (`FirebaseApp.configure()` in Swift) "
39-
@"before using "
40-
@"Firebase Database."];
35+
[NSException
36+
raise:@"FIRAppNotConfigured"
37+
format:@"The default FirebaseApp instance must be "
38+
@"configured before the default Database instance "
39+
@"can be initialized. One way to ensure this is to "
40+
@"call `FirebaseApp.configure()` in the App Delegate's "
41+
@"`application(_:didFinishLaunchingWithOptions:)` "
42+
@"(or the `@main` struct's initializer in SwiftUI)."];
4143
}
4244
return [FIRDatabase databaseForApp:[FIRApp defaultApp]];
4345
}

FirebaseInstallations/Source/Library/FIRInstallations.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ + (FIRInstallations *)installations {
189189
if (!defaultApp) {
190190
[NSException raise:kFirebaseInstallationsErrorDomain
191191
format:@"The default FirebaseApp instance must be configured before the default"
192-
@"FirebaseApp instance can be initialized. One way to ensure that is to "
193-
@"call `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) in the App"
194-
@" Delegate's `application:didFinishLaunchingWithOptions:` "
195-
@"(`application(_:didFinishLaunchingWithOptions:)` in Swift)."];
192+
@"FirebaseApp instance can be initialized. One way to ensure this is to "
193+
@"call `FirebaseApp.configure()` in the App Delegate's "
194+
@"`application(_:didFinishLaunchingWithOptions:)` "
195+
@"(or the `@main` struct's initializer in SwiftUI)."];
196196
}
197197

198198
return [self installationsWithApp:defaultApp];

0 commit comments

Comments
 (0)