-
Notifications
You must be signed in to change notification settings - Fork 716
fix(storage): wrap non-StorageError exceptions in StorageUnknownError #2554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { ErrorNamespace, isStorageError, StorageError } from './errors' | ||
| import { ErrorNamespace, isStorageError, StorageError, StorageUnknownError } from './errors' | ||
| import { Fetch } from './fetch' | ||
| import { normalizeHeaders, setHeader as setHeaderUtil } from './headers' | ||
| import { resolveFetch } from './helpers' | ||
|
|
@@ -98,7 +98,10 @@ export default abstract class BaseApiClient<TError extends StorageError = Storag | |
| if (isStorageError(error)) { | ||
| return { data: null, error: error as TError } | ||
| } | ||
| throw error | ||
| return { | ||
| data: null, | ||
| error: new StorageUnknownError(_getErrorMessage(error), error) as unknown as TError, | ||
| } | ||
|
Comment on lines
+101
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Preserve the client error namespace.
🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Do not let message extraction escape the error handler.
_getErrorMessagefalls back toJSON.stringify, which throws for values containing circular references orbigint. Because it runs inside thiscatch, such inputs are re-thrown instead of returning the documented{ data: null, error }tuple. Guard the extraction with a fallback message, or make_getErrorMessagetotal for arbitrary thrown values.🤖 Prompt for AI Agents