{"record":{"id":"24f50005cb7dc6ea","repo":"janhq/jan","slug":"tauri-error-0","errorCode":null,"errorMessage":"Tauri error: {0}","messagePattern":"Tauri error: (.+?)","errorType":"exception","errorClass":"ServerError","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs","lineNumber":202,"sourceCode":"}\n\nfn push_library(found: &mut Vec<String>, candidate: &str) {\n    let candidate = candidate.trim_matches(['\\'', '\"', '(', ')', ',', '.'].as_ref());\n    if looks_like_library(candidate) && !found.iter().any(|f| f == candidate) {\n        found.push(candidate.to_string());\n    }\n}\n\n// Error type for server commands\n#[derive(Debug, thiserror::Error)]\npub enum ServerError {\n    #[error(transparent)]\n    Llamacpp(#[from] LlamacppError),\n\n    #[error(\"IO error: {0}\")]\n    Io(#[from] std::io::Error),\n\n    #[error(\"Tauri error: {0}\")]\n    Tauri(#[from] tauri::Error),\n\n    #[error(\"Invalid argument: {0}\")]\n    InvalidArgument(String),\n}\n\n// impl serialization for tauri\nimpl serde::Serialize for ServerError {\n    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>\n    where\n        S: serde::Serializer,\n    {\n        let error_to_serialize: LlamacppError = match self {\n            ServerError::Llamacpp(err) => err.clone(),\n            ServerError::Io(e) => LlamacppError::new(\n                ErrorCode::IoError,\n                \"An input/output error occurred.\".into(),\n                Some(e.to_string()),","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs#L184-L220","documentation":"ServerError::Tauri wraps tauri::Error from command handlers, displayed as \"Tauri error: {0}\". It is produced via #[from] when Tauri framework operations inside a command (window/app state access, event emission, plugin calls) fail. It keeps framework-level failures distinct from plugin-level LlamacppErrors.","triggerScenarios":"A command uses app state, webview windows, or Tauri APIs that return tauri::Error (e.g. manager access on a torn-down window, failed event emit), auto-converted into ServerError by the #[from] impl.","commonSituations":"Emitting events to a closed webview, accessing state before setup completes, or invoking Tauri APIs from an invalid app context during shutdown or multi-window scenarios.","solutions":["Inspect the wrapped tauri::Error message to see which framework call failed.","Guard event emissions against missing targets (e.g. get_window returning None).","Ensure managed state is set up in tauri::Builder::setup before commands access it.","Avoid calling Tauri APIs after app exit has begun."],"exampleFix":"// before\napp.emit(\"llama-progress\", payload)?;\n// after\nif let Some(w) = app.get_webview_window(\"main\") {\n    w.emit(\"llama-progress\", payload)?;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match cmd() {\n    Err(ServerError::Tauri(e)) => { log::warn!(\"tauri op failed: {e}\"); degrade_gracefully(); }\n    other => other,\n}","preventionTips":["Check for the target window/webview before emitting events.","Initialize managed state in Builder::setup before any command runs.","Avoid Tauri API calls during app shutdown or from detached windows."],"tags":["rust","tauri","framework-error"],"backgroundTag":"api-error-response","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"}