Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 3 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

Catching errors with app.config.errorHandler in Vue

An app-level error handler gives you one place to receive errors thrown by components anywhere in the app.

All Vue examples Vue: usage and stats

Catching errors with app.config.errorHandler in Vue: screenshot of the example below running
The code below, running in Chromium on our server (Oct 12, 2026). Press Run to see it live and change it.

How it works

  1. Set the handler on app.config. app.config.errorHandler is a function that receives the error. This one pushes err.message into a ref that the page renders as a list. [1]
  2. Configure before mounting. The handler is assigned before app.mount(root). The Broken child throws during setup on the first render, and its error appears in the list. [1]
  3. Errors from event handlers. The red button's onClick throws a new error each time. It lands in the same list next to the setup error. [1]

Run and edit it

It runs in your browser, in a sandboxed frame that cannot see this site; the packages load from esm.sh only after you press Run.

import { createApp, ref, h } from "vue";

const root = document.getElementById("root");
root.style.cssText = "height:100%;display:grid;place-items:center;background:#111;font-family:system-ui,sans-serif";

const card = "background:#fff;color:#1f2937;padding:20px 24px;border-radius:14px;width:360px;box-shadow:0 10px 30px rgba(0,0,0,.5)";
const errors = ref([]);

// a child component that fails while it is being set up
const Broken = {
  setup() {
    throw new Error("Broken component: setup() failed");
  },
};

const app = createApp({
  setup() {
    return () =>
      h("div", { style: card }, [
        h("h2", { style: "margin:0 0 12px;font-size:18px;color:#35495e" }, "app.config.errorHandler"),
        h(Broken),
        h("button", {
          style: "padding:8px 14px;border:0;border-radius:8px;background:#ef4444;color:#fff;font-weight:600;cursor:pointer",
          onClick: () => {
            throw new Error(`Click handler failed at ${new Date().toLocaleTimeString()}`);
          },
        }, "Throw from a click handler"),
        h("p", { style: "margin:14px 0 6px;font-weight:600" }, `Caught errors (${errors.value.length}):`),
        h("ol", { style: "margin:0;padding-left:20px;font:13px ui-monospace,monospace;color:#b91c1c" },
          errors.value.map((msg, i) => h("li", { key: i }, msg))
        ),
      ]);
  },
});

// set before mount(), so errors thrown while mounting are caught too
app.config.errorHandler = (err) => {
  errors.value.push(err.message);
};

app.mount(root);
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

Press the red button a few times: each thrown error is added to the list. Code written by AgentGid [1].

Checked Oct 12, 2026: it starts without errors in Chromium with vue 3.5.43. Needs WebGL.

More Vue examples

A reactive counter with createApp and ref in Vue Options API in Vue: data, methods and mounted Render functions with h() in Vue Multiple Vue apps on one page

Sources

  1. Docs: Creating a Vue Application {#creating-a-vue-application}

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with Vue? Ask AgentGid →