pub enum Error {
Show 38 variants
Io(Error),
Json(Error),
Pdf(String),
DocumentNotFound(String),
ChunkNotFound(String),
Embedding(String),
Indexing(String),
Retrieval(String),
Storage(String),
Config(String),
Network(String),
Daemon(String),
Validation(String),
NotFound {
resource: String,
},
IoMessage {
message: String,
},
Parse {
message: String,
},
Qdrant(String),
Tantivy(String),
ConfigError(String),
WithContext {
context: String,
source: Box<dyn Error + Send + Sync>,
},
Mcp(String),
M2ExecutionError(String),
RateLimitExceeded,
BudgetExceeded(f64, f64),
M2ProtocolValidation(String),
M2ConstraintViolation(String),
M2FrameworkIncompatibility(String),
ResourceExhausted(String),
TemplateNotFound(String),
CodeIntelligence(String),
M2IntegrationError(String),
Timeout(String),
DependencyNotMet(String),
ProtocolGenerationError(String),
ThinkToolExecutionError(String),
RateLimit(String),
Authentication(String),
Authorization(String),
}Expand description
Error types for ReasonKit Core.
This enum encompasses all error conditions that can occur during ReasonKit operations. Each variant carries context-specific information to aid in debugging and error recovery.
§Example
use reasonkit::Error;
// Create specific error types
let validation_err = Error::Validation("Invalid input".to_string());
let not_found_err = Error::NotFound { resource: "document:123".to_string() };
// Add context to existing errors
let io_error = std::io::Error::new(std::io::ErrorKind::NotFound, "file missing");
let wrapped = Error::with_context("Loading config", io_error);Variants§
Io(Error)
I/O error from standard library operations.
Automatically converted from std::io::Error.
Json(Error)
JSON serialization/deserialization error.
Automatically converted from serde_json::Error.
Pdf(String)
PDF processing error.
Occurs during PDF parsing, text extraction, or page processing.
DocumentNotFound(String)
Document not found in the knowledge base.
The document ID does not exist or has been deleted.
ChunkNotFound(String)
Chunk not found within a document.
The chunk ID does not exist or the document has been re-chunked.
Embedding(String)
Embedding generation or retrieval error.
Occurs during vector embedding operations.
Indexing(String)
Indexing operation error.
Occurs during document indexing or index updates.
Retrieval(String)
Retrieval operation error.
Occurs during document or chunk retrieval.
Storage(String)
Storage operation error.
Occurs during database or file storage operations.
Config(String)
Configuration error.
Invalid or missing configuration values.
Network(String)
Network/HTTP error.
Occurs during API calls, downloads, or network operations.
Daemon(String)
MCP Daemon error.
Occurs during daemon lifecycle management (start, stop, IPC).
Validation(String)
Schema validation error.
Input data does not conform to expected schema.
NotFound
Generic resource not found error.
Use this when a resource type is dynamic or not covered by specific variants.
§Example
use reasonkit::Error;
let err = Error::NotFound { resource: "protocol:gigathink".to_string() };
assert!(err.to_string().contains("gigathink"));IoMessage
I/O error with custom message.
Use when you need to provide additional context beyond what the standard I/O error contains.
Parse
Parse error with custom message.
Use for parsing failures that aren’t JSON-specific.
Qdrant(String)
Qdrant vector database error.
Occurs during Qdrant operations.
Tantivy(String)
Tantivy search engine error.
Occurs during Tantivy indexing or search operations.
ConfigError(String)
Config library parsing error.
Occurs when configuration files cannot be parsed.
WithContext
Generic error with context chain.
Use Error::with_context() to create this variant.
§Example
use reasonkit::Error;
let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "file missing");
let err = Error::with_context("Loading configuration file", io_err);
assert!(err.to_string().contains("Loading configuration"));Fields
Mcp(String)
MCP (Model Context Protocol) error.
Occurs during MCP server/client operations.
M2ExecutionError(String)
M2 API execution error.
Occurs during MiniMax M2 model API calls.
RateLimitExceeded
M2 rate limit exceeded.
The API rate limit has been exceeded. Retry after waiting.
BudgetExceeded(f64, f64)
M2 budget exceeded.
The configured budget limit has been reached. Contains (actual_cost, budget_limit).
M2ProtocolValidation(String)
M2 protocol validation error.
The protocol definition or output failed validation.
M2ConstraintViolation(String)
M2 constraint violation.
A protocol constraint was not satisfied.
M2FrameworkIncompatibility(String)
M2 framework incompatibility.
The requested operation is not compatible with the current framework.
ResourceExhausted(String)
Resource exhausted (memory, connections, etc.).
A system resource has been exhausted.
TemplateNotFound(String)
Template not found.
The requested protocol or profile template does not exist.
CodeIntelligence(String)
Code intelligence error.
Occurs during code parsing or analysis.
M2IntegrationError(String)
M2 integration error.
General M2 integration failure.
Timeout(String)
Timeout error.
An operation exceeded its time limit.
DependencyNotMet(String)
Dependency not met.
A required dependency (step, component, etc.) was not satisfied.
ProtocolGenerationError(String)
Protocol generation error.
Failed to generate a protocol definition.
ThinkToolExecutionError(String)
ThinkTool execution error.
A ThinkTool failed during execution.
RateLimit(String)
Rate limit error.
API rate limiting was triggered.
Authentication(String)
Authentication error.
Authentication failed (invalid or missing credentials).
Authorization(String)
Authorization error.
The authenticated user lacks permission for the operation.
Implementations§
Source§impl Error
impl Error
Sourcepub fn query(msg: impl Into<String>) -> Self
pub fn query(msg: impl Into<String>) -> Self
Create a query error from a message.
This is an alias for retrieval().
§Arguments
msg- Descriptive error message
Sourcepub fn validation(msg: impl Into<String>) -> Self
pub fn validation(msg: impl Into<String>) -> Self
Sourcepub fn with_context<E>(context: impl Into<String>, source: E) -> Self
pub fn with_context<E>(context: impl Into<String>, source: E) -> Self
Wrap an error with additional context.
This creates an error chain, preserving the original error while adding context about what operation was being attempted.
§Arguments
context- Description of the operation that failedsource- The underlying error
§Example
use reasonkit::Error;
fn load_config(path: &str) -> Result<(), Error> {
std::fs::read_to_string(path)
.map_err(|e| Error::with_context(
format!("Loading config from {}", path),
e
))?;
Ok(())
}Trait Implementations§
Source§impl Error for Error
impl Error for Error
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
Source§impl From<GigaThinkError> for Error
impl From<GigaThinkError> for Error
Source§fn from(err: GigaThinkError) -> Self
fn from(err: GigaThinkError) -> Self
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
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 more