MCPcopy Create free account
hub / github.com/TanStack/query / triggerError

Function triggerError

packages/query-devtools/src/Devtools.tsx:1666–1689  ·  view source on GitHub ↗
(errorType?: DevtoolsErrorType)

Source from the content-addressed store, hash-verified

1664 }
1665
1666 const triggerError = (errorType?: DevtoolsErrorType) => {
1667 const activeQueryVal = activeQuery()
1668 if (!activeQueryVal) return
1669 sendDevToolsEvent({
1670 type: 'TRIGGER_ERROR',
1671 queryHash: activeQueryVal.queryHash,
1672 metadata: { error: errorType?.name },
1673 })
1674 const error =
1675 errorType?.initializer(activeQueryVal) ??
1676 new Error('Unknown error from devtools')
1677
1678 const __previousQueryOptions = activeQueryVal.options
1679
1680 activeQueryVal.setState({
1681 data: undefined,
1682 status: 'error',
1683 error,
1684 fetchMeta: {
1685 ...activeQueryVal.state.fetchMeta,
1686 __previousQueryOptions,
1687 } as any,
1688 })
1689 }
1690
1691 const restoreQueryAfterLoadingOrError = () => {
1692 const activeQueryVal = activeQuery()

Callers 1

QueryDetailsFunction · 0.85

Calls 2

sendDevToolsEventFunction · 0.85
setStateMethod · 0.80

Tested by

no test coverage detected