diff --git a/src/infra/storage/local-storage-adapter.ts b/src/infra/storage/local-storage-adapter.ts index aa90ff2..296ebd8 100644 --- a/src/infra/storage/local-storage-adapter.ts +++ b/src/infra/storage/local-storage-adapter.ts @@ -1,6 +1,9 @@ import {Storage} from '@/data/protocols/storage/storage'; -import {StorageGetError} from '@/domain/errors/storage-get-error'; -import {StorageSetError} from '@/domain/errors/storage-set-error'; +import { + StorageClearError, + StorageGetError, + StorageSetError, +} from '@/domain/errors'; import AsyncStorage from '@react-native-async-storage/async-storage'; export class LocalStorageAdapter implements Storage { @@ -20,6 +23,10 @@ export class LocalStorageAdapter implements Storage { } } async clear(key: string): Promise { - await AsyncStorage.removeItem(key); + try { + await AsyncStorage.removeItem(key); + } catch (error) { + throw new StorageClearError(); + } } }