diegosouzapw/OmniRoute · error · Error

(data as ).error || errorMessage

Error message

(data as { error?: string }).error || errorMessage

What it means

Export-download guard in SystemStorageTab: fetchAndDownload() GETs an export API URL expecting a Blob; on non-ok it parses the body as JSON and throws data.error (the server's sanitized reason) or the caller-supplied fallback errorMessage. It means a backup/export download never started — the file was not written to disk.

Solutions

  1. Read data.error from the failed response — it names the export-side cause
  2. Confirm sufficient disk/data state for the export being requested
  3. Retry the download once the endpoint succeeds
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/app/(dashboard)/dashboard/settings/components/SystemStorageTab.tsx:508 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/d9f06ad54c17393a. Report an issue: GitHub.

Appendix: source

Thrown at src/app/(dashboard)/dashboard/settings/components/SystemStorageTab.tsx:508

    const a = document.createElement("a");
    a.href = url;
    a.download = filename;
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    URL.revokeObjectURL(url);
  };

  /** Fetches a URL, reads the response as a Blob and triggers a download. */
  const fetchAndDownload = async (
    apiUrl: string,
    fallbackFilename: string,
    errorMessage: string
  ) => {
    const res = await fetch(apiUrl);
    if (!res.ok) {
      const data = await res.json().catch(() => ({}));
      throw new Error((data as { error?: string }).error || errorMessage);
    }
    const blob = await res.blob();
    const disposition = res.headers.get("Content-Disposition") || "";
    const filenameMatch = disposition.match(/filename="?([^"]+)"?/);
    triggerDownload(blob, filenameMatch?.[1] || fallbackFilename);
  };

  const handleExportJson = async () => {
    setExportLoading(true);
    try {
      await fetchAndDownload(
        "/api/settings/export-json",
        `omniroute-legacy-backup-${new Date().toISOString().replace(/[:.]/g, "-")}.json`,
        t("jsonExportFailed")
      );
    } catch (err) {
      console.error("Export JSON failed:", err);
      setImportStatus({

View on GitHub (pinned to a179ffed5b)