Expand description
Error types and result aliases for ReasonKit operations.
All ReasonKit functions return Result<T> which is an alias
for std::result::Result<T, Error>.
Error types for ReasonKit Core.
This module defines the error types used throughout ReasonKit Core.
All public functions return Result<T> which is an alias for
std::result::Result<T, Error>.
§Error Handling Philosophy
ReasonKit follows these error handling principles:
- Fail Fast, Fail Loud - Errors are surfaced immediately with actionable messages
- Typed Errors - Each error variant carries specific context for the failure mode
- Error Chaining - Use
with_context()to add context while preserving the source
§Example
use reasonkit::{Error, Result};
fn process_document(path: &str) -> Result<()> {
// Return typed errors
if path.is_empty() {
return Err(Error::Validation("Path cannot be empty".to_string()));
}
// Create errors with context
std::fs::read_to_string(path)
.map_err(|e| Error::io(format!("Failed to read {}", path)))?;
Ok(())
}§Error Categories
| Category | Variants | Typical Cause |
|---|---|---|
| I/O | Io, IoMessage | File operations, network I/O |
| Parsing | Json, Parse | Malformed input, schema violations |
| Resource | NotFound, DocumentNotFound | Missing documents, chunks |
| Processing | Embedding, Indexing, Retrieval | Pipeline failures |
| Configuration | Config, ConfigError | Invalid settings |
| M2 Integration | M2* variants | MiniMax M2 API issues |
Enums§
- Error
- Error types for ReasonKit Core.
Traits§
- Result
Ext - Extension trait for adding context to Results.
Type Aliases§
- Result
- Result type alias for ReasonKit operations.