Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/review-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@react-native-async-storage/async-storage": patch
---

Return existing AsyncStorageError instances, handle null rejection values safely, and classify LegacyStorageException as OtherStorageError.

5 changes: 3 additions & 2 deletions packages/async-storage/src/AsyncStorageError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class AsyncStorageError extends Error {
static nativeError(e: unknown): AsyncStorageError {
// do not override own error
if (e instanceof AsyncStorageError) {
throw e;
return e;
}

const error = getNativeError(e);
Expand All @@ -58,6 +58,7 @@ export class AsyncStorageError extends Error {
errorType = AsyncStorageErrorType.SqliteStorageError;
break;
case "OtherException":
case "LegacyStorageException":
errorType = AsyncStorageErrorType.OtherStorageError;
break;
}
Expand All @@ -77,7 +78,7 @@ export class AsyncStorageError extends Error {

// Native module reject promises with special code
function isNativeError(e: unknown): e is PotentialNativeError {
if (typeof e !== "object") {
if (e === null || typeof e !== "object") {
return false;
}

Expand Down
Loading