Public declaration syntax from forge-rs/crates/forge-generate/src/error.rs Original source SHA-256: 8e7abb146991d947e6df860feb7b8a11d14db181b016ccf85e7515c7c723bb97 Function bodies and constant values are omitted. This is not the complete implementation. Source line 33 #[derive(Debug, Error)] pub enum ForgeGenerateError { /// The language model returned an error during inference. /// /// This wraps errors from the underlying `LanguageModel::generate()` or /// `LanguageModel::stream()` calls, including provider-side failures, /// rate limits, and network errors. #[error("model '{model}' returned an error during generation: {reason}")] ModelError { /// The model identifier (e.g., "gpt-4o"). model: String, /// The error message from the provider. reason: String, }, /// The model's output failed schema validation. /// /// Occurs during structured output generation ([`generate_object()`] / /// [`stream_object()`]) when the model produces JSON that does not /// conform to the provided schema. /// /// [`generate_object()`]: crate::generate_object /// [`stream_object()`]: crate::stream_object #[error("schema violation at path '{path}': {reason} (model={model})")] SchemaViolation { /// The model identifier. model: String, /// JSON pointer path to the failing field. path: String, /// Human-readable description of the schema expectation. reason: String, }, /// The maximum step limit was reached during multi-step generation. /// /// Occurs when [`generate_steps()`] exhausts its stop condition without /// the model producing a terminal response. /// /// [`generate_steps()`]: crate::generate_steps #[error("step limit reached after {steps_completed} steps (limit={limit}, total_tokens={total_tokens})")] StepLimitReached { /// The number of steps completed before the limit was hit. steps_completed: u32, /// The configured step limit. limit: u32, /// Total tokens consumed across all steps. total_tokens: u64, }, /// A streaming response was interrupted before completion. /// /// Occurs when `LanguageModel::stream()` returns chunks that do not /// include a terminal `Done` chunk, indicating the stream was cut short. #[error("stream interrupted for model '{model}' after {chunks_received} chunks: {reason}")] StreamInterrupted { /// The model identifier. model: String, /// The number of chunks received before the interruption. chunks_received: usize, /// Explanation of what went wrong. reason: String, }, /// The model returned no response content. /// /// Occurs when the model's response message contains no text parts and /// no tool calls, which is an unexpected provider behavior. #[error("model '{model}' returned no response content for {messages_count} input messages")] NoResponse { /// The model identifier. model: String, /// The number of input messages that were sent. messages_count: usize, }, /// JSON deserialization of the model output failed. /// /// Occurs during structured output generation when the model's text /// output cannot be parsed as valid JSON or cannot be deserialized /// into the target type. #[error("failed to deserialize model output as {target_type}: {reason} (model={model})")] DeserializationFailed { /// The model identifier. model: String, /// The name of the target type being deserialized to. target_type: String, /// The deserialization error message. reason: String, }, /// A `forge-core` error occurred during generation. #[error("core error: {0}")] Core(#[from] forge_core::error::ForgeError), }