supercode-runtime 0.4.8

Optional native model and tool runtime for Supercode
Documentation
//! Errors produced by the optional native model runtime.

use thiserror::Error;

/// Result type for native runtime operations.
pub type Result<T> = std::result::Result<T, RuntimeError>;

/// A provider-transport or response error.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum RuntimeError {
    /// The HTTP transport failed.
    #[error("http transport error: {0}")]
    Http(#[source] Box<dyn std::error::Error + Send + Sync>),

    /// The provider returned a non-success status.
    #[error("provider returned status {status}: {body}")]
    Provider {
        /// HTTP status code.
        status: u16,
        /// Raw response body, truncated before construction when necessary.
        body: String,
    },

    /// A provider response could not be decoded.
    #[error("failed to decode provider response: {0}")]
    Decode(#[from] serde_json::Error),
}

impl From<reqwest::Error> for RuntimeError {
    fn from(error: reqwest::Error) -> Self {
        Self::Http(Box::new(error))
    }
}