MCPcopy Create free account
hub / github.com/TanStack/db / reportError

Function reportError

packages/db/src/query/effect.ts:1099–1116  ·  view source on GitHub ↗

Report an error to the onError callback or console

(
  error: unknown,
  event: DeltaEvent<TRow, TKey>,
  onError?: (error: Error, event: DeltaEvent<TRow, TKey>) => void,
)

Source from the content-addressed store, hash-verified

1097
1098/** Report an error to the onError callback or console */
1099function reportError<TRow extends object, TKey extends string | number>(
1100 error: unknown,
1101 event: DeltaEvent<TRow, TKey>,
1102 onError?: (error: Error, event: DeltaEvent<TRow, TKey>) => void,
1103): void {
1104 const normalised = error instanceof Error ? error : new Error(String(error))
1105 if (onError) {
1106 try {
1107 onError(normalised, event)
1108 } catch (onErrorError) {
1109 // Don't let onError errors propagate
1110 console.error(`[Effect] Error in onError handler:`, onErrorError)
1111 console.error(`[Effect] Original error:`, normalised)
1112 }
1113 } else {
1114 console.error(`[Effect] Unhandled error in handler:`, normalised)
1115 }
1116}

Callers 1

onBatchProcessedFunction · 0.85

Calls 1

onErrorFunction · 0.85

Tested by

no test coverage detected