{"record":{"id":"24f50005cb7dc6ea","repo":"janhq/jan","slug":"tauri-error-0","errorCode":null,"errorMessage":"Tauri error: {0}","messagePattern":"Tauri error: (.+?)","errorType":"exception","errorClass":"ServerError::Tauri","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs","lineNumber":200,"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":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs#L182-L218","documentation":"The ServerError::Tauri variant (#[from] tauri::Error) in the tauri-plugin-llamacpp plugin. Its Display is \"Tauri error: {0}\". On serialization it is mapped to a LlamacppError with code INTERNAL_ERROR and message \"An internal application error occurred.\", the Tauri error string kept in details. It captures failures from the Tauri runtime/IPC layer rather than llama.cpp itself.","triggerScenarios":"A command calls a Tauri API (managed state access, event emit, app handle operation) that returns tauri::Error, and `?` converts it into ServerError::Tauri.","commonSituations":"Emitting an event to a webview that no longer exists; accessing managed state that was not registered; IPC/app-handle misuse; Tauri version mismatch causing API errors.","solutions":["Verify any Tauri managed state is registered before the command runs.","Guard event emissions against missing/disposed webview targets.","Align the plugin with the installed Tauri version (API surface changes).","Inspect the serialized `details` for the specific tauri::Error variant."],"exampleFix":"// Rust\npub fn emit_progress(app: AppHandle) -> ServerResult<()> {\n    app.emit(\"progress\", 1)?; // tauri::Error -> ServerError::Tauri\n    Ok(())\n}\n\n// Frontend\ncatch (e) {\n  const err = JSON.parse(e.message)\n  if (err.code === 'INTERNAL_ERROR') logger.error('Tauri runtime error:', err.details)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await invoke('start_server', { ... })\n} catch (e) {\n  const err = JSON.parse((e as any).message ?? '{}')\n  if (err.code === 'INTERNAL_ERROR') reportRuntimeError(err.details)\n  else throw e\n}","preventionTips":["Register all managed state the command expects.","Guard event emissions against disposed webviews.","Keep the plugin and Tauri versions aligned."],"tags":["rust","tauri","error-handling","ipc","runtime"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}