Files
rustytorch/crates/training/rtx-rl/src/error.rs
T
2026-03-04 00:08:42 +00:00

52 lines
1.3 KiB
Rust

use thiserror::Error;
#[derive(Error, Debug, Clone)]
pub enum RLError {
#[error("Tensor operation error: {0}")]
TensorError(String),
#[error("Environment error: {0}")]
EnvironmentError(String),
#[error("Replay buffer error: {0}")]
ReplayBufferError(String),
#[error("Algorithm error: {0}")]
AlgorithmError(String),
#[error("Actor-Learner error: {0}")]
ActorLearnerError(String),
#[error("Insufficient data: required {required}, available {available}")]
InsufficientData { required: usize, available: usize },
#[error("Invalid configuration: {0}")]
InvalidConfig(String),
#[error("Communication error: {0}")]
CommunicationError(String),
#[error("Serialization error: {0}")]
SerializationError(String),
}
impl From<rtx_tensor::TensorError> for RLError {
fn from(err: rtx_tensor::TensorError) -> Self {
Self::TensorError(err.to_string())
}
}
// impl From<rtx_runtime::RuntimeError> for RLError {
// fn from(err: rtx_runtime::RuntimeError) -> Self {
// RLError::TensorError(err.to_string())
// }
// }
// impl From<rtx_distributed::DistributedError> for RLError {
// fn from(err: rtx_distributed::DistributedError) -> Self {
// RLError::CommunicationError(err.to_string())
// }
// }
pub type Result<T> = std::result::Result<T, RLError>;