Skip to content
0

katanakit-js / shouldThrowError

Function: shouldThrowError() ​

ts
function shouldThrowError<T>(throwOnError, params): boolean;

Defined in: node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:1062

Resolves a throwOnError option to a boolean. If throwOnError is a function, it is called with params (e.g. the error and, depending on the caller, additional context such as the query or mutation) and its result is returned, allowing the throwing behavior to be decided per error. Otherwise, throwOnError itself is coerced to a boolean (undefined resolves to false).

Type Parameters ​

Type Parameter
T extends (...args) => boolean

Parameters ​

ParameterType
throwOnErrorboolean | T | undefined
paramsParameters<T>

Returns ​

boolean

Example ​

ts
const throwOnError =
  query.state.error && typeof options.throwOnError === 'function'
    ? shouldThrowError(options.throwOnError, [query.state.error, query])
    : options.throwOnError

Released under the MIT License.