0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-18 19:33:22 +00:00
query/docs/framework/vue/reference/functions/shouldThrowError.md
Wonsuk Choi 6e16d3946a
docs(query-core/utils): add missing JSDoc to utility functions (#11830)
* docs(query-core/utils): add missing JSDoc to utility functions

* docs(query-core/utils): clarify that 'addToEnd' and 'addToStart' drop at most one item

* docs(framework/*/reference): regenerate reference docs
2026-10-04 02:47:14 +09:00

1.2 KiB

id title
shouldThrowError shouldThrowError
function shouldThrowError<T>(throwOnError: boolean | T | undefined, params: Parameters<T>): boolean;

Defined in: packages/query-core/src/utils.ts:687

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

T

T extends (...args: any[]) => boolean

Parameters

throwOnError

The throwOnError option: a boolean, a function that decides per error, or undefined.

boolean | T | undefined

params

Parameters<T>

The arguments passed to throwOnError if it is a function.

Returns

boolean

Whether the error should be thrown.

Example

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