diegosouzapw/OmniRoute · error · Error

|| HTTP

Error message

${json.error} || HTTP ${res.status}

What it means

Shared fetchJson helper for the Combo Control Center: a GET returned non-OK and the error body had no usable error string (json.error / json.error.message missing or non-string), so the throw degrades to 'HTTP <status>'. All control-center panels route their load failures through this one normalization point.

Solutions

  1. Ensure combo API routes return structured error bodies so the message is meaningful
  2. Handle aborts before treating them as failures
  3. Check server logs for the failing combo endpoint
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/app/(dashboard)/dashboard/combos/ComboControlCenterClient.tsx:71 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/8df3eb02a5fb9a16. Report an issue: GitHub.

Appendix: source

Thrown at src/app/(dashboard)/dashboard/combos/ComboControlCenterClient.tsx:71

  critical: "border-red-500/20 bg-red-500/10 text-red-400",
  idle: "border-blue-500/20 bg-blue-500/10 text-blue-400",
};

function toArray<T>(value: unknown): T[] {
  return Array.isArray(value) ? (value as T[]) : [];
}

async function fetchJson<T>(url: string): Promise<T> {
  const res = await fetch(url, { cache: "no-store" });
  const json = await res.json().catch(() => ({}));
  if (!res.ok) {
    const message =
      typeof json?.error === "string"
        ? json.error
        : typeof json?.error?.message === "string"
          ? json.error.message
          : `HTTP ${res.status}`;
    throw new Error(message);
  }
  return json as T;
}

function fmtPercent(value: number | null | undefined): string {
  if (typeof value !== "number" || !Number.isFinite(value)) return "—";
  return `${Math.round(value)}%`;
}

function fmtMs(value: number | null | undefined): string {
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return "—";
  return `${Math.round(value)}ms`;
}

function fmtDate(value: string | null | undefined): string {
  if (!value) return "—";
  const date = new Date(value);
  if (Number.isNaN(date.getTime())) return "—";

View on GitHub (pinned to a179ffed5b)