Skip to content

Commit 51dd1ac

Browse files
jonsimantova-maurice
authored andcommitted
Add error logging if you try to call setPersistenceEnabled on iOS after using
the database, rather than it just failing silently. PiperOrigin-RevId: 270151202
1 parent 3a832df commit 51dd1ac

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

database/src/ios/database_ios.mm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
delete listener;
6767
}
6868
}
69+
impl_ = MakeUnique<FIRDatabasePointer>(nil);
6970
}
7071

7172
App* DatabaseInternal::GetApp() { return app_; }
@@ -102,7 +103,13 @@ new DatabaseReferenceInternal(const_cast<DatabaseInternal*>(this),
102103
return g_sdk_version->c_str();
103104
}
104105

105-
void DatabaseInternal::SetPersistenceEnabled(bool enabled) { impl().persistenceEnabled = enabled; }
106+
void DatabaseInternal::SetPersistenceEnabled(bool enabled) {
107+
@try {
108+
impl().persistenceEnabled = enabled;
109+
} @catch (NSException* e) {
110+
LogError("SetPersistenceEnabled error: %s", e.reason.UTF8String);
111+
}
112+
}
106113

107114
void DatabaseInternal::set_log_level(LogLevel log_level) {
108115
// iOS FIRDatabase only supports logging or not logging. Since the default logging level (Info)

0 commit comments

Comments
 (0)