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

utils.ts

16 lines572 Bytes

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