Skip to content

Commit

Permalink
fix: react-query: add name, stack, cause to error
Browse files Browse the repository at this point in the history
  • Loading branch information
nitedani committed Mar 31, 2024
1 parent 109603b commit 7a99687
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vike-react-query/src/withFallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type RetryOptions = { retryQuery?: boolean }
type RetryFn = (options?: RetryOptions) => void

type ErrorFallbackProps = {
error: { message: string }
error: { message: string } & Record<string, unknown>
retry: RetryFn
}

Expand Down Expand Up @@ -63,6 +63,11 @@ export function withFallback<T extends object = Record<string, never>>(
const error = { message }
if (typeof originalError === 'object') {
Object.assign(error, originalError)
for (const key of ['name', 'stack', 'cause']) {
if (key in originalError) {
Object.assign(error, { [key]: originalError[key] })
}
}
}
return error
}
Expand Down

0 comments on commit 7a99687

Please sign in to comment.