llama_cpp_bindings/error/
grammar_error.rs1use std::ffi::NulError;
2
3use crate::error::token_to_string_error::TokenToStringError;
4
5#[derive(Debug, thiserror::Error, PartialEq, Eq)]
6pub enum GrammarError {
7 #[error("the approximate token environment could not be built: {0}")]
8 TokEnvUnavailable(#[from] TokenToStringError),
9 #[error("grammar root not found in grammar string")]
10 RootNotFound,
11 #[error("trigger word contains null bytes: {0}")]
12 TriggerWordNullBytes(NulError),
13 #[error("grammar string or root contains null bytes: {0}")]
14 GrammarNullBytes(NulError),
15 #[error("string contains null bytes: {0}")]
16 NulError(#[from] NulError),
17 #[error("integer overflow: {0}")]
18 IntegerOverflow(String),
19 #[error("llguidance error: {0}")]
20 LlguidanceError(String),
21 #[error("grammar is malformed")]
22 GrammarMalformed,
23 #[error("lazy grammar is malformed")]
24 LazyGrammarMalformed,
25 #[error("lazy-patterns grammar is malformed")]
26 LazyPatternsGrammarMalformed,
27 #[error("trigger pattern is not a valid regex: {message}")]
28 InvalidTriggerPattern { message: String },
29 #[error("llguidance sampler could not be created")]
30 LlguidanceSamplerUnavailable,
31 #[error("not enough memory")]
32 NotEnoughMemory,
33 #[error("{message}")]
34 Reported { message: String },
35}