janhq/jan · error · Error

${error.message}

Error message

${error.message}

What it means

A pass-through re-throw inside getModels' catch block. When the caught error's message starts with one of the structured prefixes ('Authentication failed', 'Access forbidden', 'Models endpoint not found', or 'Failed to fetch models from') it re-wraps and re-throws the identical message so callers receive the original human-readable cause instead of the generic connection/fallback wrappers below it.

Source

Thrown at web-app/src/services/providers/tauri.ts:267

      )
    } catch (error) {
      console.error('Error fetching models from provider:', error)

      // Preserve structured error messages thrown above
      const structuredErrorPrefixes = [
        'Authentication failed',
        'Access forbidden',
        'Models endpoint not found',
        'Failed to fetch models from',
      ]

      if (
        error instanceof Error &&
        structuredErrorPrefixes.some((prefix) =>
          (error as Error).message.startsWith(prefix)
        )
      ) {
        throw new Error(error.message)
      }

      // Provide helpful error message for any connection errors
      if (error instanceof Error && error.message.includes('fetch')) {
        throw new Error(
          `Cannot connect to ${provider.provider} at ${provider.base_url}. Please check that the service is running and accessible.`
        )
      }

      // Generic fallback
      throw new Error(
        `Unexpected error while fetching models from ${provider.provider}: ${error instanceof Error ? error.message : 'Unknown error'}`
      )
    }
  }

  async updateSettings(
    providerName: string,

View on GitHub (pinned to fad3f12a14)

Solutions

  1. Read error.message to find the real cause; this line just preserves a deeper throw.
  2. Trace back to the matching structured throw (401/403/404 handler or error 160/161) for the actual fix.
Defensive patterns

Strategy: try-catch

Type guard

const STRUCTURED_PREFIXES = [
  'Authentication failed',
  'Access forbidden',
  'Models endpoint not found',
  'Failed to fetch models from',
]
function isStructuredProviderError(e: unknown): boolean {
  return e instanceof Error && STRUCTURED_PREFIXES.some(p => e.message.startsWith(p))
}

Try / catch

try {
  models = await provider.getModels(p)
} catch (e) {
  if (isStructuredProviderError(e)) showErrorToast(e.message)
  else throw e
}

Prevention

When it happens

Trigger: Any of the structured throws inside the try block (the 401, 403, 404 handlers, error 160, or error 161) is caught by the surrounding try/catch and matched by prefix, then re-thrown verbatim here.

Common situations: Normal error propagation. This is a relay, not a new failure - the real cause is the structured throw whose message is being preserved.

Related errors


AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12). Data as JSON: /api/errors/96ed2584ceb869dc. Report an issue: GitHub.