3232#import " Firestore/Source/API/FIRFirestore+Internal.h"
3333#import " Firestore/Source/API/FSTFirestoreComponent.h"
3434#import " Firestore/Source/API/FSTUserDataConverter.h"
35- #import " Firestore/Source/Util/FSTUsageValidation.h"
3635
3736#include " Firestore/core/src/firebase/firestore/api/firestore.h"
37+ #include " Firestore/core/src/firebase/firestore/api/input_validation.h"
3838#include " Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
3939#include " Firestore/core/src/firebase/firestore/core/database_info.h"
4040#include " Firestore/core/src/firebase/firestore/model/database_id.h"
4646namespace util = firebase::firestore::util;
4747using firebase::firestore::api::DocumentReference;
4848using firebase::firestore::api::Firestore;
49+ using firebase::firestore::api::ThrowIllegalState;
50+ using firebase::firestore::api::ThrowInvalidArgument;
4951using firebase::firestore::auth::CredentialsProvider;
5052using firebase::firestore::model::DatabaseId;
5153using firebase::firestore::util::AsyncQueue;
@@ -109,9 +111,8 @@ + (void)initialize {
109111+ (instancetype )firestore {
110112 FIRApp *app = [FIRApp defaultApp ];
111113 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" );
115116 }
116117 return [self firestoreForApp: app database:util: :WrapNSString (DatabaseId: :kDefault )];
117118}
@@ -123,13 +124,13 @@ + (instancetype)firestoreForApp:(FIRApp *)app {
123124// TODO(b/62410906): make this public
124125+ (instancetype )firestoreForApp : (FIRApp *)app database : (NSString *)database {
125126 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." );
128129 }
129130 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 );
133134 }
134135
135136 id <FSTFirestoreMultiDBProvider> provider =
@@ -182,22 +183,21 @@ - (FSTFirestoreClient *)client {
182183
183184- (FIRCollectionReference *)collectionWithPath : (NSString *)collectionPath {
184185 if (!collectionPath) {
185- FSTThrowInvalidArgument ( @ " Collection path cannot be nil." );
186+ ThrowInvalidArgument ( " Collection path cannot be nil." );
186187 }
187188 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);
190190 }
191191
192192 return _firestore->GetCollection (util::MakeString (collectionPath));
193193}
194194
195195- (FIRDocumentReference *)documentWithPath : (NSString *)documentPath {
196196 if (!documentPath) {
197- FSTThrowInvalidArgument ( @ " Document path cannot be nil." );
197+ ThrowInvalidArgument ( " Document path cannot be nil." );
198198 }
199199 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);
201201 }
202202
203203 DocumentReference documentReference = _firestore->GetDocument (util::MakeString (documentPath));
@@ -215,9 +215,9 @@ - (void)runTransactionWithBlock:(id _Nullable (^)(FIRTransaction *, NSError **))
215215 // We wrap the function they provide in order to use internal implementation classes for
216216 // transaction, and to run the user callback block on the proper queue.
217217 if (!updateBlock) {
218- FSTThrowInvalidArgument ( @ " Transaction block cannot be nil." );
218+ ThrowInvalidArgument ( " Transaction block cannot be nil." );
219219 } else if (!completion) {
220- FSTThrowInvalidArgument ( @ " Transaction completion block cannot be nil." );
220+ ThrowInvalidArgument ( " Transaction completion block cannot be nil." );
221221 }
222222
223223 _firestore->RunTransaction (updateBlock, queue, completion);
@@ -275,11 +275,11 @@ + (FIRFirestore *)recoverFromFirestore:(Firestore *)firestore {
275275
276276- (FIRQuery *)collectionGroupWithID : (NSString *)collectionID {
277277 if (!collectionID) {
278- FSTThrowInvalidArgument ( @ " Collection ID cannot be nil." );
278+ ThrowInvalidArgument ( " Collection ID cannot be nil." );
279279 }
280280 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);
283283 }
284284
285285 return _firestore->GetCollectionGroup (collectionID);
0 commit comments