32
32
#import " Firestore/Source/API/FIRFirestore+Internal.h"
33
33
#import " Firestore/Source/API/FSTFirestoreComponent.h"
34
34
#import " Firestore/Source/API/FSTUserDataConverter.h"
35
- #import " Firestore/Source/Util/FSTUsageValidation.h"
36
35
37
36
#include " Firestore/core/src/firebase/firestore/api/firestore.h"
37
+ #include " Firestore/core/src/firebase/firestore/api/input_validation.h"
38
38
#include " Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
39
39
#include " Firestore/core/src/firebase/firestore/core/database_info.h"
40
40
#include " Firestore/core/src/firebase/firestore/model/database_id.h"
46
46
namespace util = firebase::firestore::util;
47
47
using firebase::firestore::api::DocumentReference;
48
48
using firebase::firestore::api::Firestore;
49
+ using firebase::firestore::api::ThrowIllegalState;
50
+ using firebase::firestore::api::ThrowInvalidArgument;
49
51
using firebase::firestore::auth::CredentialsProvider;
50
52
using firebase::firestore::model::DatabaseId;
51
53
using firebase::firestore::util::AsyncQueue;
@@ -109,9 +111,8 @@ + (void)initialize {
109
111
+ (instancetype )firestore {
110
112
FIRApp *app = [FIRApp defaultApp ];
111
113
if (!app) {
112
- FSTThrowInvalidUsage (@" FIRAppNotConfiguredException" ,
113
- @" Failed to get FirebaseApp instance. Please call FirebaseApp.configure() "
114
- @" before using Firestore" );
114
+ ThrowIllegalState (" Failed to get FirebaseApp instance. Please call FirebaseApp.configure() "
115
+ " before using Firestore" );
115
116
}
116
117
return [self firestoreForApp: app database:util: :WrapNSString (DatabaseId: :kDefault )];
117
118
}
@@ -123,13 +124,13 @@ + (instancetype)firestoreForApp:(FIRApp *)app {
123
124
// TODO(b/62410906): make this public
124
125
+ (instancetype )firestoreForApp : (FIRApp *)app database : (NSString *)database {
125
126
if (!app) {
126
- FSTThrowInvalidArgument ( @ " FirebaseApp instance may not be nil. Use FirebaseApp.app() if you'd "
127
- " like to use the default FirebaseApp instance." );
127
+ ThrowInvalidArgument ( " FirebaseApp instance may not be nil. Use FirebaseApp.app() if you'd like "
128
+ " to use the default FirebaseApp instance." );
128
129
}
129
130
if (!database) {
130
- FSTThrowInvalidArgument ( @" database identifier may not be nil. Use '%s ' if you want the default "
131
- " database" ,
132
- DatabaseId::kDefault );
131
+ ThrowInvalidArgument ( " Database identifier may not be nil. Use '%s' if you want the default "
132
+ " database" ,
133
+ DatabaseId::kDefault );
133
134
}
134
135
135
136
id <FSTFirestoreMultiDBProvider> provider =
@@ -182,22 +183,21 @@ - (FSTFirestoreClient *)client {
182
183
183
184
- (FIRCollectionReference *)collectionWithPath : (NSString *)collectionPath {
184
185
if (!collectionPath) {
185
- FSTThrowInvalidArgument ( @ " Collection path cannot be nil." );
186
+ ThrowInvalidArgument ( " Collection path cannot be nil." );
186
187
}
187
188
if ([collectionPath containsString: @" //" ]) {
188
- FSTThrowInvalidArgument (@" Invalid path (%@ ). Paths must not contain // in them." ,
189
- collectionPath);
189
+ ThrowInvalidArgument (" Invalid path (%s). Paths must not contain // in them." , collectionPath);
190
190
}
191
191
192
192
return _firestore->GetCollection (util::MakeString (collectionPath));
193
193
}
194
194
195
195
- (FIRDocumentReference *)documentWithPath : (NSString *)documentPath {
196
196
if (!documentPath) {
197
- FSTThrowInvalidArgument ( @ " Document path cannot be nil." );
197
+ ThrowInvalidArgument ( " Document path cannot be nil." );
198
198
}
199
199
if ([documentPath containsString: @" //" ]) {
200
- FSTThrowInvalidArgument ( @ " Invalid path (%@ ). Paths must not contain // in them." , documentPath);
200
+ ThrowInvalidArgument ( " Invalid path (%s ). Paths must not contain // in them." , documentPath);
201
201
}
202
202
203
203
DocumentReference documentReference = _firestore->GetDocument (util::MakeString (documentPath));
@@ -215,9 +215,9 @@ - (void)runTransactionWithBlock:(id _Nullable (^)(FIRTransaction *, NSError **))
215
215
// We wrap the function they provide in order to use internal implementation classes for
216
216
// transaction, and to run the user callback block on the proper queue.
217
217
if (!updateBlock) {
218
- FSTThrowInvalidArgument ( @ " Transaction block cannot be nil." );
218
+ ThrowInvalidArgument ( " Transaction block cannot be nil." );
219
219
} else if (!completion) {
220
- FSTThrowInvalidArgument ( @ " Transaction completion block cannot be nil." );
220
+ ThrowInvalidArgument ( " Transaction completion block cannot be nil." );
221
221
}
222
222
223
223
_firestore->RunTransaction (updateBlock, queue, completion);
@@ -275,11 +275,11 @@ + (FIRFirestore *)recoverFromFirestore:(Firestore *)firestore {
275
275
276
276
- (FIRQuery *)collectionGroupWithID : (NSString *)collectionID {
277
277
if (!collectionID) {
278
- FSTThrowInvalidArgument ( @ " Collection ID cannot be nil." );
278
+ ThrowInvalidArgument ( " Collection ID cannot be nil." );
279
279
}
280
280
if ([collectionID containsString: @" /" ]) {
281
- FSTThrowInvalidArgument (
282
- @" Invalid collection ID ( %@ ). Collection IDs must not contain / in them. " , collectionID);
281
+ ThrowInvalidArgument ( " Invalid collection ID (%s). Collection IDs must not contain / in them. " ,
282
+ collectionID);
283
283
}
284
284
285
285
return _firestore->GetCollectionGroup (collectionID);
0 commit comments