janhq/jan · error · WebSearchError

WebSearchError

Error message

WebSearchError: {message}

What it means

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).

Solutions

  1. Read the message field for the underlying cause
  2. Verify the provider name passed to create_provider() matches a supported provider
  3. Check network connectivity and provider API status
  4. Retry the search command if the failure was transient

Example fix

// before
invoke('web_search', { provider: 'gogle', query });
// after
invoke('web_search', { provider: 'google', query }); // use a supported provider id
Defensive patterns

Strategy: try-catch

Validate before calling

const SUPPORTED = ['google', 'bing', 'duckduckgo'];
if (!SUPPORTED.includes(provider)) throw new Error(`unsupported provider: ${provider}`);

Try / catch

try {
  const results = await invoke<SearchResult[]>('web_search', { provider, query });
} catch (e) {
  const msg = String(e);
  if (msg.startsWith('WebSearchError:')) {
    console.warn('search failed:', msg.slice('WebSearchError:'.length));
    // show fallback UI / retry
  }
}

Prevention

When it happens

Trigger: A websearch command invokes create_provider() for an unknown provider name, or a provider call fails and the error is mapped into WebSearchError::new(...).

Common situations: Passing an unsupported provider identifier from the frontend, provider API outages, or network failures surfacing as a generic WebSearchError message.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17). Data as JSON: /api/errors/89a326dacffe43ca. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/plugins/tauri-plugin-websearch/src/commands.rs:5

use crate::provider::{clamp_count, create_provider, FetchedPage, SearchResult};
use serde::Serialize;

#[derive(Debug, Clone, Serialize, thiserror::Error)]
#[error("WebSearchError: {message}")]
pub struct WebSearchError {
    pub message: String,
}

impl WebSearchError {
    fn new(message: impl Into<String>) -> Self {
        Self {
            message: message.into(),
        }
    }
}

impl From<String> for WebSearchError {
    fn from(message: String) -> Self {
        Self::new(message)
    }
}

View on GitHub (pinned to 7205d770c1)