janhq/jan · error · LlamacppError

LlamacppError {{ code: {code:?}, message: "{message}" }}

Error message

LlamacppError {{ code: {code:?}, message: "{message}" }}

What it means

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.

Source

Thrown at src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs:33

    ModelLoadTimedOut,
    LlamaCppProcessError,
    MissingSharedLibrary,
    GpuDriverTooOld,

    // --- Memory Errors ---
    OutOfMemory,

    // --- Configuration Errors ---
    InvalidArgument,

    // --- Internal Application Errors ---
    DeviceListParseFailed,
    IoError,
    InternalError,
}

#[derive(Debug, Clone, Serialize, thiserror::Error)]
#[error("LlamacppError {{ code: {code:?}, message: \"{message}\" }}")]
pub struct LlamacppError {
    pub code: ErrorCode,
    pub message: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub details: Option<String>,
    /// Library names the loader could not resolve, so the UI can turn them into
    /// install advice instead of showing raw stderr.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub missing_libraries: Option<Vec<String>>,
}

impl LlamacppError {
    pub fn new(code: ErrorCode, message: String, details: Option<String>) -> Self {
        Self {
            code,
            message,
            details,
            missing_libraries: None,

View on GitHub (pinned to fad3f12a14)

Solutions

  1. Match on the serialized `code` field (e.g. OUT_OF_MEMORY, MISSING_SHARED_LIBRARY) to choose the user-facing remedy.
  2. For MISSING_SHARED_LIBRARY, read missing_libraries[] to install the named dependency.
  3. For OUT_OF_MEMORY, load a smaller/quantized model or free GPU memory.
  4. For GPU_DRIVER_TOO_OLD / MODEL_ARCH_NOT_SUPPORTED, update the driver or use a compatible model/backend.

Example fix

// frontend handling
try {
  await invoke('start_server', { ... })
} catch (e) {
  const err = JSON.parse(e.message ?? '{}')
  switch (err.code) {
    case 'OUT_OF_MEMORY': alert('Not enough memory; use a smaller model')
    case 'MISSING_SHARED_LIBRARY': promptInstall(err.missing_libraries)
    default: console.error(err.message, err.details)
  }
}
Defensive patterns

Strategy: try-catch

Type guard

function isLlamacppError(e: unknown): e is { code: string; message: string; details?: string; missing_libraries?: string[] } {
  return typeof e === 'object' && e !== null && 'code' in e && 'message' in e
}

Try / catch

try {
  await invoke('start_server', { ... })
} catch (e) {
  const err = typeof e === 'string' ? JSON.parse(e) : (e as any)
  switch (err.code) {
    case 'OUT_OF_MEMORY': handleOOM()
    case 'MISSING_SHARED_LIBRARY': promptInstall(err.missing_libraries)
    case 'GPU_DRIVER_TOO_OLD': promptDriverUpdate()
    default: console.error(err.message, err.details)
  }
}

Prevention

When it happens

Trigger: Any llamacpp Tauri command (model load, inference, embed, device list) returns Err(LlamacppError); the frontend receives the serialized {code, message, details?, missing_libraries?} object.

Common situations: 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.

Related errors


AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12). Data as JSON: /api/errors/4c80c66e8db05645. Report an issue: GitHub.