roplat 0.2.0

roplat: just a robot operation system
Documentation
use thiserror::Error;

/// Unified roplat error enum.
///
/// This type aggregates common error sources across modules. For finer-grained
/// errors, keep module-specific context and convert via `Into<RoplatError>`.
#[derive(Error, Debug)]
pub enum RoplatError {
    /// Arithmetic error.
    #[error("算术错误: {0}")]
    Arithmetic(String),

    /// I/O error (auto-converted from `std::io::Error`).
    #[error("IO 错误: {0}")]
    Io(#[from] std::io::Error),

    /// Node processing/business error.
    #[error("节点处理错误: {0}")]
    NodeProcessing(String),

    /// Resource access/state error.
    #[error("资源错误: {0}")]
    Resource(String),

    /// JSON serialization/deserialization error.
    #[error("序列化错误: {0}")]
    Serialization(#[from] serde_json::Error),

    /// Uncategorized error.
    #[error("其他错误: {0}")]
    Other(String),
}

/// Public roplat result alias.
///
/// # Example
/// ```rust
/// use roplat::{RoplatError, RoplatResult};
///
/// fn parse_positive(v: i32) -> RoplatResult<i32> {
///     if v > 0 { Ok(v) } else { Err(RoplatError::Other("not positive".into())) }
/// }
///
/// assert!(parse_positive(1).is_ok());
/// assert!(parse_positive(0).is_err());
/// ```
pub type RoplatResult<T> = Result<T, RoplatError>;