{"record":{"id":"36e1b67a9937f826","repo":"janhq/jan","slug":"databaseerror","errorCode":"DatabaseError","errorMessage":"Database error: {0}","messagePattern":"Database error: (.+?)","errorType":"error_code","errorClass":"VectorDBError","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-vector-db/src/error.rs","lineNumber":5,"sourceCode":"use serde::{Deserialize, Serialize};\n\n#[derive(Debug, thiserror::Error, Serialize, Deserialize)]\npub enum VectorDBError {\n    #[error(\"Database error: {0}\")]\n    DatabaseError(String),\n\n    #[error(\"Invalid input: {0}\")]\n    InvalidInput(String),\n}\n\nimpl From<rusqlite::Error> for VectorDBError {\n    fn from(err: rusqlite::Error) -> Self {\n        VectorDBError::DatabaseError(err.to_string())\n    }\n}\n\nimpl From<serde_json::Error> for VectorDBError {\n    fn from(err: serde_json::Error) -> Self {\n        VectorDBError::DatabaseError(err.to_string())\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/src-tauri/plugins/tauri-plugin-vector-db/src/error.rs#L1-L23","documentation":"VectorDBError::DatabaseError is the catch-all variant of the vector-db plugin's error enum. It wraps any underlying database failure (typically a rusqlite::Error converted via the From impl) into a string message prefixed with 'Database error:'. It is thrown whenever a SQLite operation in the plugin fails.","triggerScenarios":"Any rusqlite operation that fails inside the plugin (connection open, query execution, transaction commit) is converted via From<rusqlite::Error> into VectorDBError::DatabaseError(err.to_string()).","commonSituations":"Corrupt or locked SQLite file, missing database directory, disk-full, schema migration mismatch after a plugin version upgrade, or concurrent writes hitting SQLite's busy lock.","solutions":["Inspect the wrapped string (the rusqlite error text) to identify the exact SQLite failure","Verify the database file path exists and its parent directory is writable","Check no other process holds a write lock on the SQLite file","If a schema mismatch, delete/migrate the DB file so the plugin can recreate it"],"exampleFix":"// before\nlet conn = Connection::open(path)?;\n// after\nif let Some(dir) = std::path::Path::new(&path).parent() {\n    std::fs::create_dir_all(dir)?; // ensure parent exists before opening\n}\nlet conn = Connection::open(path).map_err(|e| VectorDBError::DatabaseError(e.to_string()))?;","handlingStrategy":"try-catch","validationCode":"import std::path::Path;\nif !Path::new(&db_path).parent().map_or(false, |p| p.exists()) {\n    std::fs::create_dir_all(Path::new(&db_path).parent().unwrap())?;\n}","typeGuard":null,"tryCatchPattern":"match plugin_command() {\n    Err(VectorDBError::DatabaseError(msg)) => { log::error!(\"db failure: {msg}\"); /* retry or surface to UI */ }\n    other => other?,\n}","preventionTips":["Ensure the DB directory exists and is writable before opening","Enable WAL mode to reduce lock contention","Wrap rusqlite calls with busy_timeout","Log the wrapped rusqlite message for actionable diagnostics"],"tags":["database","sqlite","rust","tauri-plugin"],"backgroundTag":"database-query-failed","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"}