Use try/catch

This commit is contained in:
Eric Bailey
2023-11-21 10:08:15 -06:00
parent cf73b8fe4d
commit 8aaea79d4c
2 changed files with 13 additions and 6 deletions
+7 -3
View File
@@ -139,7 +139,11 @@ export async function migrate() {
}
export async function clearLegacyStorage() {
await AsyncStorage.removeItem(DEPRECATED_ROOT_STATE_STORAGE_KEY, e => {
if (e) console.error(e)
})
try {
await AsyncStorage.removeItem(DEPRECATED_ROOT_STATE_STORAGE_KEY)
} catch (e: any) {
logger.error(`persisted legacy store: failed to clear`, {
error: e.toString(),
})
}
}
+6 -3
View File
@@ -1,6 +1,7 @@
import AsyncStorage from '@react-native-async-storage/async-storage'
import {Schema, schema} from '#/state/persisted/schema'
import {logger} from '#/logger'
const BSKY_STORAGE = 'BSKY_STORAGE'
@@ -18,7 +19,9 @@ export async function read(): Promise<Schema | undefined> {
}
export async function clear() {
await AsyncStorage.removeItem(BSKY_STORAGE, e => {
if (e) console.error(e)
})
try {
await AsyncStorage.removeItem(BSKY_STORAGE)
} catch (e: any) {
logger.error(`persisted store: failed to clear`, {error: e.toString()})
}
}