Error

Enum Error 

Source
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"));

Fields

§resource: String

Resource identifier that was not found

§

IoMessage

I/O error with custom message.

Use when you need to provide additional context beyond what the standard I/O error contains.

Fields

§message: String

Descriptive error message

§

Parse

Parse error with custom message.

Use for parsing failures that aren’t JSON-specific.

Fields

§message: String

Descriptive error message

§

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

§context: String

Description of what operation was being attempted

§source: Box<dyn Error + Send + Sync>

The underlying error

§

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

Source

pub fn io(msg: impl Into<String>) -> Self

Create an I/O error from a message.

§Arguments
  • msg - Descriptive error message
§Example
use reasonkit::Error;

let err = Error::io("Failed to open file");
assert!(err.to_string().contains("Failed to open"));
Source

pub fn parse(msg: impl Into<String>) -> Self

Create a parse error from a message.

§Arguments
  • msg - Descriptive error message
§Example
use reasonkit::Error;

let err = Error::parse("Invalid JSON syntax at line 42");
Source

pub fn pdf(msg: impl Into<String>) -> Self

Create a PDF processing error from a message.

§Arguments
  • msg - Descriptive error message
Source

pub fn embedding(msg: impl Into<String>) -> Self

Create an embedding error from a message.

§Arguments
  • msg - Descriptive error message
Source

pub fn indexing(msg: impl Into<String>) -> Self

Create an indexing error from a message.

§Arguments
  • msg - Descriptive error message
Source

pub fn retrieval(msg: impl Into<String>) -> Self

Create a retrieval error from a message.

§Arguments
  • msg - Descriptive error message
Source

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
Source

pub fn storage(msg: impl Into<String>) -> Self

Create a storage error from a message.

§Arguments
  • msg - Descriptive error message
Source

pub fn config(msg: impl Into<String>) -> Self

Create a config error from a message.

§Arguments
  • msg - Descriptive error message
Source

pub fn network(msg: impl Into<String>) -> Self

Create a network error from a message.

§Arguments
  • msg - Descriptive error message
Source

pub fn daemon(msg: impl Into<String>) -> Self

Create a daemon error from a message.

§Arguments
  • msg - Descriptive error message
Source

pub fn validation(msg: impl Into<String>) -> Self

Create a validation error from a message.

§Arguments
  • msg - Descriptive error message
§Example
use reasonkit::Error;

let err = Error::validation("Input must not be empty");
Source

pub fn with_context<E>(context: impl Into<String>, source: E) -> Self
where E: Error + Send + Sync + 'static,

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 failed
  • source - 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 Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Convert reqwest errors to our Error type.

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<GigaThinkError> for Error

Source§

fn from(err: GigaThinkError) -> Self

Converts to this type from the input type.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,