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

Function triggerError

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

Source from the content-addressed store, hash-verified

2049 }
2050
2051 const triggerError = (errorType?: DevtoolsErrorType) => {
2052 const activeQueryVal = activeQuery()
2053 if (!activeQueryVal) return
2054 sendDevToolsEvent({
2055 type: 'TRIGGER_ERROR',
2056 queryHash: activeQueryVal.queryHash,
2057 metadata: { error: errorType?.name },
2058 })
2059 const error =
2060 errorType?.initializer(activeQueryVal) ??
2061 new Error('Unknown error from devtools')
2062
2063 const __previousQueryOptions = activeQueryVal.options
2064
2065 activeQueryVal.setState({
2066 data: undefined,
2067 status: 'error',
2068 error,
2069 fetchMeta: {
2070 ...activeQueryVal.state.fetchMeta,
2071 __previousQueryOptions,
2072 } as any,
2073 })
2074 }
2075
2076 const restoreQueryAfterLoadingOrError = () => {
2077 const activeQueryVal = activeQuery()

Callers 1

QueryDetailsFunction · 0.85

Calls 2

sendDevToolsEventFunction · 0.85
setStateMethod · 0.80

Tested by

no test coverage detected