MCPcopy
hub / github.com/TanStack/query / triggerError

Function triggerError

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

Source from the content-addressed store, hash-verified

1879 }
1880
1881 const triggerError = (errorType?: DevtoolsErrorType) => {
1882 const activeQueryVal = activeQuery()
1883 if (!activeQueryVal) return
1884 sendDevToolsEvent({
1885 type: 'TRIGGER_ERROR',
1886 queryHash: activeQueryVal.queryHash,
1887 metadata: { error: errorType?.name },
1888 })
1889 const error =
1890 errorType?.initializer(activeQueryVal) ??
1891 new Error('Unknown error from devtools')
1892
1893 const __previousQueryOptions = activeQueryVal.options
1894
1895 activeQueryVal.setState({
1896 status: 'error',
1897 error,
1898 fetchMeta: {
1899 ...activeQueryVal.state.fetchMeta,
1900 __previousQueryOptions,
1901 } as any,
1902 } as QueryState<unknown, Error>)
1903 }
1904
1905 const restoreQueryAfterLoadingOrError = () => {
1906 const activeQueryVal = activeQuery()

Callers 1

QueryDetailsFunction · 0.85

Calls 2

sendDevToolsEventFunction · 0.85
setStateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…