Manual Error Capture
useErrorBoundary() — for programmatic use outside a template <ErrorBoundary>: e.g. a custom layout-level error state in Nuxt, or registering errors from code that errorCaptured never sees.
const { error, hasError, reset, captureError } = useErrorBoundary({
onError: (e) => report(e),
reporter: myReporter,
})
try {
JSON.parse(untrustedInput)
} catch (err) {
captureError(err, { source: 'manual', componentName: 'ImportPanel' })
}Options
onError
(error: CapturedError) => void · default: —
Called for every captured error.
beforeReset
() => void · default: —
Called right before reset() clears state.
reporter
ErrorReporter | ErrorReporter[] · default: —
Reporter(s) invoked once per captured error — see Reporting adapters.
reportContext
Record<string, unknown> · default: —
Extra context merged into every report() call.
internalErrorPrefix
string · default: '[vue-error-boundary-kit]'
Prefix for the internal safety-net log emitted when your own onError/reporter itself throws (see the <ErrorBoundary> note — same default, same reasoning, though there's no naming collision risk here since this is a plain composable, not a component with its own reset emit). Pass '' to omit it.
Return value
captureError
(err: unknown, info?: CaptureErrorInfo) => CapturedError
Registers an error manually; returns the resulting CapturedError.
reset
() => void
Clears error back to null.
error
ShallowRef<CapturedError | null>
hasError
ComputedRef<boolean>