pub enum AppError {
Show 17 variants
Validation(String),
Duplicate(String),
Conflict(String),
NotFound(String),
NamespaceError(String),
LimitExceeded(String),
Database(Error),
Embedding(String),
VecExtension(String),
DbBusy(String),
BatchPartialFailure {
total: usize,
failed: usize,
},
Io(Error),
Internal(Error),
Json(Error),
LockBusy(String),
AllSlotsFull {
max: usize,
waited_secs: u64,
},
LowMemory {
available_mb: u64,
required_mb: u64,
},
}Expand description
Unified error type for all CLI and library operations.
Each variant corresponds to a distinct failure category. The
AppError::exit_code method converts a variant into a stable numeric
code so that shell callers and LLM agents can route on it.
Variants§
Validation(String)
Input failed schema, length or format validation. Maps to exit code 1.
Duplicate(String)
A memory or entity with the same (namespace, name) already exists. Maps to exit code 2.
Conflict(String)
Optimistic update lost the race because updated_at changed. Maps to exit code 3.
NotFound(String)
The requested record does not exist or was soft-deleted. Maps to exit code 4.
NamespaceError(String)
Namespace could not be resolved from flag, environment or markers. Maps to exit code 5.
LimitExceeded(String)
Payload exceeded one of the configured body, name or batch limits. Maps to exit code 6.
Database(Error)
Low-level SQLite error propagated from rusqlite. Maps to exit code 10.
Embedding(String)
Embedding generation via fastembed failed or produced the wrong shape. Maps to exit code 11.
VecExtension(String)
The sqlite-vec extension could not load or register its virtual table. Maps to exit code 12.
DbBusy(String)
SQLite returned SQLITE_BUSY after exhausting retries. Maps to exit code 15 (antes de v2.0.0 era 13; movido para liberar 13 para BatchPartialFailure conforme PRD).
BatchPartialFailure
Batch operation failed partially — N of M items failed. Maps to exit code 13 (PRD 1822).
Reservado para uso em import, reindex e batch stdin (BLOCO 3/4). Variante presente
desde v2.0.0 mesmo que call-sites ainda não existam — mapeamento estável de exit code.
Io(Error)
Filesystem I/O error while reading or writing the database or cache. Maps to exit code 14.
Internal(Error)
Unexpected internal error surfaced through anyhow. Maps to exit code 20.
Json(Error)
JSON serialization or deserialization failure. Maps to exit code 20.
LockBusy(String)
Another instance is already running and holds the advisory lock. Maps to exit code 75.
Use --allow-parallel to skip the lock or --wait-lock SECONDS to retry.
AllSlotsFull
Todos os slots de concorrência estão ocupados após o tempo de espera. Maps to exit code 75.
Ocorre quando crate::constants::MAX_CONCURRENT_CLI_INSTANCES instâncias já estão
ativas e o limite de espera crate::constants::CLI_LOCK_DEFAULT_WAIT_SECS foi esgotado.
LowMemory
Memória disponível abaixo do mínimo para carregar o modelo. Maps to exit code 77.
Retornado quando sysinfo reporta memória disponível inferior a
crate::constants::MIN_AVAILABLE_MEMORY_MB MiB antes de iniciar o carregamento ONNX.
Implementations§
Source§impl AppError
impl AppError
Sourcepub fn exit_code(&self) -> i32
pub fn exit_code(&self) -> i32
Returns the deterministic process exit code for this error variant.
The codes follow the contract documented in the README: 1 for
validation, 2 for duplicates, 3 for conflicts, 4 for missing
records, 5 for namespace errors, 6 for limit violations, 10–14
for infrastructure failures, 13 for BatchPartialFailure (PRD 1822),
15 for DbBusy (migrated from 13 in v2.0.0), 20 for internal errors,
75 (EX_TEMPFAIL) when the advisory CLI lock is held or all concurrency
slots are exhausted, and 77 when available memory is insufficient to
load the embedding model.
§Examples
use sqlite_graphrag::errors::AppError;
assert_eq!(AppError::Validation("campo inválido".into()).exit_code(), 1);
assert_eq!(AppError::Duplicate("ns/mem".into()).exit_code(), 2);
assert_eq!(AppError::Conflict("ts mudou".into()).exit_code(), 3);
assert_eq!(AppError::NotFound("id 42".into()).exit_code(), 4);
assert_eq!(AppError::NamespaceError("sem marcador".into()).exit_code(), 5);
assert_eq!(AppError::LimitExceeded("corpo grande".into()).exit_code(), 6);
assert_eq!(AppError::Embedding("dim errada".into()).exit_code(), 11);
assert_eq!(AppError::DbBusy("retries esgotados".into()).exit_code(), 15);
assert_eq!(AppError::LockBusy("outra instância".into()).exit_code(), 75);Sourcepub fn localized_message(&self) -> String
pub fn localized_message(&self) -> String
Retorna a mensagem de erro localizada no idioma ativo (--lang / SQLITE_GRAPHRAG_LANG).
Em inglês, o texto é idêntico ao Display gerado por thiserror.
Em português, os prefixos e mensagens são traduzidos para PT-BR.
Sourcepub fn localized_message_for(&self, lang: Language) -> String
pub fn localized_message_for(&self, lang: Language) -> String
Retorna a mensagem localizada para o idioma explicitamente fornecido.
Útil em testes que não podem depender do OnceLock global.
§Examples
use sqlite_graphrag::errors::AppError;
use sqlite_graphrag::i18n::Language;
let err = AppError::NotFound("mem-xyz".into());
let en = err.localized_message_for(Language::English);
assert!(en.contains("not found"));
let pt = err.localized_message_for(Language::Portugues);
assert!(pt.contains("não encontrado"));Trait Implementations§
Source§impl Error for AppError
impl Error for AppError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for AppError
impl !RefUnwindSafe for AppError
impl Send for AppError
impl Sync for AppError
impl Unpin for AppError
impl UnsafeUnpin for AppError
impl !UnwindSafe for AppError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more