Skip to content

Commit 76b8da6

Browse files
authored
Rename FirestoreErrorCode to just Error (#3460)
1 parent 3188760 commit 76b8da6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+275
-296
lines changed

Firestore/Example/Tests/Core/FSTQueryListenerTests.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "Firestore/core/src/firebase/firestore/util/statusor.h"
4141
#include "Firestore/core/test/firebase/firestore/testutil/xcgmock.h"
4242

43-
using firebase::firestore::FirestoreErrorCode;
43+
using firebase::firestore::Error;
4444
using firebase::firestore::core::AsyncEventListener;
4545
using firebase::firestore::core::EventListener;
4646
using firebase::firestore::core::DocumentViewChange;
@@ -149,7 +149,7 @@ - (void)testRaisesErrorEvent {
149149
accum.push_back(maybe_snapshot.status());
150150
});
151151

152-
Status testError{FirestoreErrorCode::Unauthenticated, "Some info"};
152+
Status testError{Error::Unauthenticated, "Some info"};
153153
listener->OnError(testError);
154154

155155
XC_ASSERT_THAT(accum, ElementsAre(testError));

Firestore/Example/Tests/Local/FSTLRUGarbageCollectorTests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ NS_ASSUME_NONNULL_BEGIN
3030

3131
@end
3232

33-
NS_ASSUME_NONNULL_END
33+
NS_ASSUME_NONNULL_END

Firestore/Example/Tests/Local/FSTLevelDBMigrationsTests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
NS_ASSUME_NONNULL_BEGIN
3939

40-
using firebase::firestore::FirestoreErrorCode;
40+
using firebase::firestore::Error;
4141
using firebase::firestore::local::LevelDbCollectionParentKey;
4242
using firebase::firestore::local::LevelDbDocumentMutationKey;
4343
using firebase::firestore::local::LevelDbDocumentTargetKey;

Firestore/Example/Tests/Local/FSTMemoryLRUGarbageCollectorTests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ - (BOOL)sentinelExists:(const DocumentKey &)key {
4444

4545
@end
4646

47-
NS_ASSUME_NONNULL_END
47+
NS_ASSUME_NONNULL_END

Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
namespace testutil = firebase::firestore::testutil;
6464
namespace util = firebase::firestore::util;
6565
using firebase::Timestamp;
66-
using firebase::firestore::FirestoreErrorCode;
66+
using firebase::firestore::Error;
6767
using firebase::firestore::core::FieldFilter;
6868
using firebase::firestore::model::DatabaseId;
6969
using firebase::firestore::model::DocumentKey;
@@ -853,7 +853,7 @@ - (void)testConvertsTargetChangeWithRemoved {
853853
WatchTargetChange expected{WatchTargetChangeState::Removed,
854854
{1, 4},
855855
FSTTestData(0, 1, 2, -1),
856-
Status{FirestoreErrorCode::PermissionDenied, "Error message"}};
856+
Status{Error::PermissionDenied, "Error message"}};
857857

858858
GCFSListenResponse *listenResponse = [GCFSListenResponse message];
859859
listenResponse.targetChange.targetChangeType = GCFSTargetChange_TargetChangeType_Remove;

Firestore/Example/Tests/SpecTests/FSTSpecTests.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
namespace objc = firebase::firestore::objc;
5959
namespace testutil = firebase::firestore::testutil;
6060
namespace util = firebase::firestore::util;
61-
using firebase::firestore::FirestoreErrorCode;
61+
using firebase::firestore::Error;
6262
using firebase::firestore::auth::User;
6363
using firebase::firestore::core::DocumentViewChange;
6464
using firebase::firestore::model::DocumentKey;
@@ -283,7 +283,7 @@ - (void)doWatchRemove:(NSDictionary *)watchRemoveSpec {
283283
NSDictionary *userInfo = @{
284284
NSLocalizedDescriptionKey : @"Error from watchRemove.",
285285
};
286-
error = Status{static_cast<FirestoreErrorCode>(code), MakeString([userInfo description])};
286+
error = Status{static_cast<Error>(code), MakeString([userInfo description])};
287287
}
288288
WatchTargetChange change{WatchTargetChangeState::Removed,
289289
ConvertTargetsArray(watchRemoveSpec[@"targetIds"]), error};

Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#include "absl/memory/memory.h"
5656

5757
namespace objc = firebase::firestore::objc;
58-
using firebase::firestore::FirestoreErrorCode;
58+
using firebase::firestore::Error;
5959
using firebase::firestore::auth::EmptyCredentialsProvider;
6060
using firebase::firestore::auth::HashUser;
6161
using firebase::firestore::auth::User;
@@ -311,7 +311,7 @@ - (FSTOutstandingWrite *)receiveWriteAckWithVersion:(const SnapshotVersion &)com
311311
- (FSTOutstandingWrite *)receiveWriteError:(int)errorCode
312312
userInfo:(NSDictionary<NSString *, id> *)userInfo
313313
keepInQueue:(BOOL)keepInQueue {
314-
Status error{static_cast<FirestoreErrorCode>(errorCode), MakeString([userInfo description])};
314+
Status error{static_cast<Error>(errorCode), MakeString([userInfo description])};
315315

316316
FSTOutstandingWrite *write = [self currentOutstandingWrites].firstObject;
317317
[self validateNextWriteSent:write.write];
@@ -408,7 +408,7 @@ - (void)receiveWatchChange:(const WatchChange &)change
408408
}
409409

410410
- (void)receiveWatchStreamError:(int)errorCode userInfo:(NSDictionary<NSString *, id> *)userInfo {
411-
Status error{static_cast<FirestoreErrorCode>(errorCode), MakeString([userInfo description])};
411+
Status error{static_cast<Error>(errorCode), MakeString([userInfo description])};
412412

413413
_workerQueue->EnqueueBlocking([&] {
414414
_datastore->FailWatchStream(error);

Firestore/Source/Core/FSTFirestoreClient.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#include "absl/memory/memory.h"
5858

5959
namespace util = firebase::firestore::util;
60-
using firebase::firestore::FirestoreErrorCode;
60+
using firebase::firestore::Error;
6161
using firebase::firestore::api::DocumentReference;
6262
using firebase::firestore::api::DocumentSnapshot;
6363
using firebase::firestore::api::Settings;
@@ -369,10 +369,10 @@ - (void)getDocumentFromLocalCache:(const DocumentReference &)doc
369369
/*from_cache=*/true,
370370
/*has_pending_writes=*/false};
371371
} else {
372-
maybe_snapshot = Status{FirestoreErrorCode::Unavailable,
373-
"Failed to get document from cache. (However, this document "
374-
"may exist on the server. Run again without setting source to "
375-
"FirestoreSourceCache to attempt to retrieve the document "};
372+
maybe_snapshot =
373+
Status{Error::Unavailable, "Failed to get document from cache. (However, this document "
374+
"may exist on the server. Run again without setting source to "
375+
"FirestoreSourceCache to attempt to retrieve the document "};
376376
}
377377

378378
if (shared_callback) {

Firestore/Source/Core/FSTSyncEngine.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#include "Firestore/core/src/firebase/firestore/util/status.h"
5151
#include "absl/types/optional.h"
5252

53-
using firebase::firestore::FirestoreErrorCode;
53+
using firebase::firestore::Error;
5454
using firebase::firestore::auth::HashUser;
5555
using firebase::firestore::auth::User;
5656
using firebase::firestore::core::TargetIdGenerator;
@@ -648,8 +648,8 @@ - (BOOL)errorIsInteresting:(NSError *)error {
648648
- (BOOL)isRetryableTransactionError:(const Status &)error {
649649
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
650650
// non-matching document versions with ABORTED. These errors should be retried.
651-
FirestoreErrorCode code = error.code();
652-
return code == FirestoreErrorCode::Aborted || code == FirestoreErrorCode::FailedPrecondition ||
651+
Error code = error.code();
652+
return code == Error::Aborted || code == Error::FailedPrecondition ||
653653
!Datastore::IsPermanentError(error);
654654
}
655655

Firestore/Source/Local/FSTLevelDB.mm

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
NS_ASSUME_NONNULL_BEGIN
5858

5959
namespace util = firebase::firestore::util;
60-
using firebase::firestore::FirestoreErrorCode;
60+
using firebase::firestore::Error;
6161
using firebase::firestore::auth::User;
6262
using firebase::firestore::core::DatabaseInfo;
6363
using firebase::firestore::local::ConvertStatus;
@@ -445,15 +445,13 @@ + (Path)storageDirectoryForDatabaseInfo:(const DatabaseInfo &)databaseInfo
445445
+ (Status)ensureDirectory:(const Path &)directory {
446446
Status status = util::RecursivelyCreateDir(directory);
447447
if (!status.ok()) {
448-
return Status{FirestoreErrorCode::Internal, "Failed to create persistence directory"}.CausedBy(
449-
status);
448+
return Status{Error::Internal, "Failed to create persistence directory"}.CausedBy(status);
450449
}
451450

452451
NSURL *dirURL = [NSURL fileURLWithPath:directory.ToNSString()];
453452
NSError *localError = nil;
454453
if (![dirURL setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:&localError]) {
455-
return Status{FirestoreErrorCode::Internal,
456-
"Failed to mark persistence directory as excluded from backups"}
454+
return Status{Error::Internal, "Failed to mark persistence directory as excluded from backups"}
457455
.CausedBy(Status::FromNSError(localError));
458456
}
459457

@@ -468,7 +466,7 @@ + (Status)ensureDirectory:(const Path &)directory {
468466
DB *database = nullptr;
469467
leveldb::Status status = DB::Open(options, directory.ToUtf8String(), &database);
470468
if (!status.ok()) {
471-
return Status{FirestoreErrorCode::Internal,
469+
return Status{Error::Internal,
472470
StringFormat("Failed to open LevelDB database at %s", directory.ToUtf8String())}
473471
.CausedBy(ConvertStatus(status));
474472
}

0 commit comments

Comments
 (0)