{"record":{"id":"89a326dacffe43ca","repo":"janhq/jan","slug":"websearcherror-message","errorCode":null,"errorMessage":"WebSearchError: {message}","messagePattern":"WebSearchError: (.+?)","errorType":"error_code","errorClass":"WebSearchError","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-websearch/src/commands.rs","lineNumber":5,"sourceCode":"use crate::provider::{clamp_count, create_provider, FetchedPage, SearchResult};\nuse serde::Serialize;\n\n#[derive(Debug, Clone, Serialize, thiserror::Error)]\n#[error(\"WebSearchError: {message}\")]\npub struct WebSearchError {\n    pub message: String,\n}\n\nimpl WebSearchError {\n    fn new(message: impl Into<String>) -> Self {\n        Self {\n            message: message.into(),\n        }\n    }\n}\n\nimpl From<String> for WebSearchError {\n    fn from(message: String) -> Self {\n        Self::new(message)\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/src-tauri/plugins/tauri-plugin-websearch/src/commands.rs#L1-L23","documentation":"WebSearchError is the plugin's single serializable error struct; its Display impl renders 'WebSearchError: <message>'. It is created via WebSearchError::new(message) by the provider layer when a search request cannot be completed (provider creation failure, clamp/count issues, or provider-reported errors).","triggerScenarios":"A websearch command invokes create_provider() for an unknown provider name, or a provider call fails and the error is mapped into WebSearchError::new(...).","commonSituations":"Passing an unsupported provider identifier from the frontend, provider API outages, or network failures surfacing as a generic WebSearchError message.","solutions":["Read the message field for the underlying cause","Verify the provider name passed to create_provider() matches a supported provider","Check network connectivity and provider API status","Retry the search command if the failure was transient"],"exampleFix":"// before\ninvoke('web_search', { provider: 'gogle', query });\n// after\ninvoke('web_search', { provider: 'google', query }); // use a supported provider id","handlingStrategy":"try-catch","validationCode":"const SUPPORTED = ['google', 'bing', 'duckduckgo'];\nif (!SUPPORTED.includes(provider)) throw new Error(`unsupported provider: ${provider}`);","typeGuard":null,"tryCatchPattern":"try {\n  const results = await invoke<SearchResult[]>('web_search', { provider, query });\n} catch (e) {\n  const msg = String(e);\n  if (msg.startsWith('WebSearchError:')) {\n    console.warn('search failed:', msg.slice('WebSearchError:'.length));\n    // show fallback UI / retry\n  }\n}","preventionTips":["Use a whitelisted provider identifier","Check network connectivity before issuing searches","Implement client-side retry with backoff for transient failures","Surface the message field to users instead of the raw error string"],"tags":["network","web-search","rust","tauri-plugin"],"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"}