rlt_core/error.rs
1//! Error type for rlt-core.
2
3use thiserror::Error;
4
5/// Unified error type for the crate.
6#[derive(Debug, Error)]
7pub enum RltError {
8 /// Errors from the candle tensor backend.
9 #[error("candle error: {0}")]
10 Candle(#[from] candle_core::Error),
11 /// Filesystem errors (checkpointing, corpora).
12 #[error("io error: {0}")]
13 Io(#[from] std::io::Error),
14 /// Invalid model or tokenizer configuration.
15 #[error("config error: {0}")]
16 Config(String),
17 /// Tokenizer misuse (ids out of range, etc.).
18 #[error("token error: {0}")]
19 Token(String),
20 /// Checkpoint save/load failures.
21 #[error("checkpoint error: {0}")]
22 Checkpoint(String),
23 /// Recurrent-state misuse (stale position, cache mismatch).
24 #[error("state error: {0}")]
25 State(String),
26 /// RL rollout/replay contract violations.
27 #[error("replay error: {0}")]
28 Replay(String),
29}
30
31/// Convenience result alias.
32pub type Result<T> = std::result::Result<T, RltError>;