Skip to content
Open
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
19 changes: 13 additions & 6 deletions packages/core/storage-js/src/packages/StorageFileApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isStorageError, StorageError, StorageUnknownError } from '../lib/errors'
import { isStorageError, StorageError, StorageUnknownError, StorageApiError } from '../lib/errors'
import { Fetch, get, head, post, put, remove } from '../lib/fetch'
import { recursiveToCamel, resolveFetch } from '../lib/helpers'
import {
Expand Down Expand Up @@ -600,14 +600,21 @@ export default class StorageFileApi {
if (this.shouldThrowOnError) {
throw error
}
if (isStorageError(error) && error instanceof StorageUnknownError) {
const originalError = error.originalError as unknown as { status: number }
if (isStorageError(error)) {
// Check for both StorageApiError (which has status directly) and StorageUnknownError (with originalError)
let status: number | undefined

if (error instanceof StorageApiError) {
status = error.status
} else if (error instanceof StorageUnknownError) {
const originalError = error.originalError as unknown as { status: number }
status = originalError?.status
}

if ([400, 404].includes(originalError?.status)) {
return { data: false, error }
if (status && [400, 404].includes(status)) {
return { data: false, error: null }
}
}

throw error
}
}
Expand Down