Skip to content

Global Error Capture

useGlobalErrorCapture() — separate entry point (vue-error-boundary-kit/global-capture), not wired up by default, so it costs nothing in bundles that don't import it (including SSR bundles, where it's a no-op if window isn't defined). Wires up window.addEventListener('error', …) and unhandledrejection, funneled through the same reporter/onError pattern as Manual Error Capture.

ts
import { useGlobalErrorCapture } from 'vue-error-boundary-kit/global-capture'

useGlobalErrorCapture({
  reporter: myReporter,
  onError: (e) => console.warn('uncaught:', e),
})

Options

onError

(error: CapturedError) => void · default: —

Called for every captured global error/rejection.

reporter

ErrorReporter | ErrorReporter[] · default: —

Reporter(s) to invoke once per captured error.

reportContext

Record<string, unknown> · default: —

Extra context merged into every report() call.

captureErrors

boolean · default: true

Listen for uncaught errors via window.onerror.

captureRejections

boolean · default: true

Listen for unhandled promise rejections.

shouldCatch

(error: CapturedError) => boolean · default: —

Return false to ignore an error entirely — no onError, no report. Useful for browser/extension noise (e.g. a benign "ResizeObserver loop" message).

internalErrorPrefix

string · default: '[vue-error-boundary-kit]'

Prefix for the internal safety-net log emitted when your own onError/reporter itself throws. Pass '' to omit it.

Return value

stop

() => void

Removes the global listeners. Also runs automatically on scope dispose, if any (e.g. a component's setup()).