{"record":{"id":"f7b87bd2166d879a","repo":"janhq/jan","slug":"error-message-tauri","errorCode":null,"errorMessage":"error.message","messagePattern":"error\\.message","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"web-app/src/services/providers/tauri.ts","lineNumber":267,"sourceCode":"      )\n    } catch (error) {\n      console.error('Error fetching models from provider:', error)\n\n      // Preserve structured error messages thrown above\n      const structuredErrorPrefixes = [\n        'Authentication failed',\n        'Access forbidden',\n        'Models endpoint not found',\n        'Failed to fetch models from',\n      ]\n\n      if (\n        error instanceof Error &&\n        structuredErrorPrefixes.some((prefix) =>\n          (error as Error).message.startsWith(prefix)\n        )\n      ) {\n        throw new Error(error.message)\n      }\n\n      // Provide helpful error message for any connection errors\n      if (error instanceof Error && error.message.includes('fetch')) {\n        throw new Error(\n          `Cannot connect to ${provider.provider} at ${provider.base_url}. Please check that the service is running and accessible.`\n        )\n      }\n\n      // Generic fallback\n      throw new Error(\n        `Unexpected error while fetching models from ${provider.provider}: ${error instanceof Error ? error.message : 'Unknown error'}`\n      )\n    }\n  }\n\n  async updateSettings(\n    providerName: string,","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/web-app/src/services/providers/tauri.ts#L249-L285","documentation":"Not a distinct error type: this is the re-throw path that preserves structured errors ('Authentication failed', 'Access forbidden', 'Models endpoint not found', 'Failed to fetch models from') thrown earlier in fetchModelsFromProvider. It re-wraps the message in a new Error so the original, specific message reaches the caller unchanged.","triggerScenarios":"Any of the four structured errors above is thrown inside the try block and then caught by the outer catch; because the message starts with a known prefix, it is re-thrown as-is.","commonSituations":"Developers see this in stack traces when debugging provider fetch failures; the visible message is the underlying 401/403/404/generic HTTP error, not a new failure.","solutions":["Diagnose based on the preserved message (see the 401/403/404/status-specific errors).","If you control the code, prefer re-throwing the original error instead of allocating a new Error to keep the original stack.","Check console.error output ('Error fetching models from provider') for the original stack."],"exampleFix":"// before\nthrow new Error(error.message)\n// after (preserves stack and type)\nthrow error","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isStructuredFetchError(e: unknown): e is Error {\n  const prefixes = ['Authentication failed', 'Access forbidden', 'Models endpoint not found', 'Failed to fetch models from']\n  return e instanceof Error && prefixes.some(p => e.message.startsWith(p))\n}","tryCatchPattern":"try {\n  await fetchModelsFromProvider(provider)\n} catch (e) {\n  if (isStructuredFetchError(e)) handleProviderHttpError(e)\n  else handleUnexpectedError(e)\n}","preventionTips":["Branch on the documented message prefixes when handling provider errors.","Prefer error classes or codes over string matching in new code.","Log console.error output to recover the original stack."],"tags":["error-handling","rethrow","provider-api"],"backgroundTag":"api-request-failed","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}