Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

utils.ts

16 lines589 Bytes

1export function shouldThrowError<T extends (...args: any[]) => boolean>(
2 suspense: boolean | undefined,
3 _useErrorBoundary: boolean | T | undefined,
4 params: Parameters<T>
5): boolean {
6 // Allow useErrorBoundary function to override throwing behavior on a per-error basis
7 if (typeof _useErrorBoundary === 'function') {
8 return _useErrorBoundary(...params)
9 }
10​
11 // Allow useErrorBoundary to override suspense's throwing behavior
12 if (typeof _useErrorBoundary === 'boolean') return _useErrorBoundary
13​
14 // If suspense is enabled default to throwing errors
15 return !!suspense