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

Function triggerError

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

Source from the content-addressed store, hash-verified

1922 }
1923
1924 const triggerError = (errorType?: DevtoolsErrorType) => {
1925 const activeQueryVal = activeQuery()
1926 if (!activeQueryVal) return
1927 sendDevToolsEvent({
1928 type: 'TRIGGER_ERROR',
1929 queryHash: activeQueryVal.queryHash,
1930 metadata: { error: errorType?.name },
1931 })
1932 const error =
1933 errorType?.initializer(activeQueryVal) ??
1934 new Error('Unknown error from devtools')
1935
1936 const __previousQueryOptions = activeQueryVal.options
1937
1938 activeQueryVal.setState({
1939 data: undefined,
1940 status: 'error',
1941 error,
1942 fetchMeta: {
1943 ...activeQueryVal.state.fetchMeta,
1944 __previousQueryOptions,
1945 } as any,
1946 })
1947 }
1948
1949 const restoreQueryAfterLoadingOrError = () => {
1950 const activeQueryVal = activeQuery()

Callers 1

QueryDetailsFunction · 0.85

Calls 2

sendDevToolsEventFunction · 0.85
setStateMethod · 0.80

Tested by

no test coverage detected