{"record":{"id":"4c80c66e8db05645","repo":"janhq/jan","slug":"llamacpperror-code-code-message-messag","errorCode":null,"errorMessage":"LlamacppError {{ code: {code:?}, message: \"{message}\" }}","messagePattern":"LlamacppError (.+?), message: \"(.+?)\" \\}\\}","errorType":"error_code","errorClass":"LlamacppError","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs","lineNumber":33,"sourceCode":"    ModelLoadTimedOut,\n    LlamaCppProcessError,\n    MissingSharedLibrary,\n    GpuDriverTooOld,\n\n    // --- Memory Errors ---\n    OutOfMemory,\n\n    // --- Configuration Errors ---\n    InvalidArgument,\n\n    // --- Internal Application Errors ---\n    DeviceListParseFailed,\n    IoError,\n    InternalError,\n}\n\n#[derive(Debug, Clone, Serialize, thiserror::Error)]\n#[error(\"LlamacppError {{ code: {code:?}, message: \\\"{message}\\\" }}\")]\npub struct LlamacppError {\n    pub code: ErrorCode,\n    pub message: String,\n    #[serde(skip_serializing_if = \"Option::is_none\")]\n    pub details: Option<String>,\n    /// Library names the loader could not resolve, so the UI can turn them into\n    /// install advice instead of showing raw stderr.\n    #[serde(skip_serializing_if = \"Option::is_none\")]\n    pub missing_libraries: Option<Vec<String>>,\n}\n\nimpl LlamacppError {\n    pub fn new(code: ErrorCode, message: String, details: Option<String>) -> Self {\n        Self {\n            code,\n            message,\n            details,\n            missing_libraries: None,","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs#L15-L51","documentation":"The canonical thiserror Display impl for the LlamacppError struct in the tauri-plugin-llamacpp Rust plugin. It is the top-level error shape serialized to the Tauri/JS frontend: a code (ErrorCode enum), a message, optional details (raw stderr), and optional missing_libraries. The UI matches on the serialized code string to pick a localized message, so the wire format is part of the contract.","triggerScenarios":"Any llamacpp Tauri command (model load, inference, embed, device list) returns Err(LlamacppError); the frontend receives the serialized {code, message, details?, missing_libraries?} object.","commonSituations":"Model load failure, OOM, missing shared library (CUDA/Vulkan), GPU driver too old, unsupported model architecture, internal IO error — all surface as a LlamacppError with a specific code.","solutions":["Match on the serialized `code` field (e.g. OUT_OF_MEMORY, MISSING_SHARED_LIBRARY) to choose the user-facing remedy.","For MISSING_SHARED_LIBRARY, read missing_libraries[] to install the named dependency.","For OUT_OF_MEMORY, load a smaller/quantized model or free GPU memory.","For GPU_DRIVER_TOO_OLD / MODEL_ARCH_NOT_SUPPORTED, update the driver or use a compatible model/backend."],"exampleFix":"// frontend handling\ntry {\n  await invoke('start_server', { ... })\n} catch (e) {\n  const err = JSON.parse(e.message ?? '{}')\n  switch (err.code) {\n    case 'OUT_OF_MEMORY': alert('Not enough memory; use a smaller model')\n    case 'MISSING_SHARED_LIBRARY': promptInstall(err.missing_libraries)\n    default: console.error(err.message, err.details)\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isLlamacppError(e: unknown): e is { code: string; message: string; details?: string; missing_libraries?: string[] } {\n  return typeof e === 'object' && e !== null && 'code' in e && 'message' in e\n}","tryCatchPattern":"try {\n  await invoke('start_server', { ... })\n} catch (e) {\n  const err = typeof e === 'string' ? JSON.parse(e) : (e as any)\n  switch (err.code) {\n    case 'OUT_OF_MEMORY': handleOOM()\n    case 'MISSING_SHARED_LIBRARY': promptInstall(err.missing_libraries)\n    case 'GPU_DRIVER_TOO_OLD': promptDriverUpdate()\n    default: console.error(err.message, err.details)\n  }\n}","preventionTips":["Always parse the `code` field and dispatch on it for user-facing advice.","Keep the ErrorCode <-> UI-message mapping in sync with the Rust enum.","Treat `details` as diagnostic-only (raw stderr), never user-facing."],"tags":["rust","llamacpp","error-handling","tauri","serialization"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}