Skip to main content

tufazip_codec/
error.rs

1use thiserror::Error;
2use tufazip_arith::ArithError;
3use tufazip_prior::PriorError;
4
5/// Errors returned by the neural codec, model initialization, optimizer, or checkpoints.
6#[derive(Debug, Error)]
7pub enum CodecError {
8    /// Underlying Candle tensor or autograd error.
9    #[error("candle error: {0}")]
10    Candle(#[from] candle_core::Error),
11
12    /// Arithmetic coding or bit stream error.
13    #[error(transparent)]
14    Arith(#[from] ArithError),
15
16    /// Quantized prior archive or validation error.
17    #[error(transparent)]
18    Prior(#[from] PriorError),
19
20    /// Underlying filesystem I/O error.
21    #[error(transparent)]
22    Io(#[from] std::io::Error),
23
24    /// JSON configuration or checkpoint metadata error.
25    #[error(transparent)]
26    Json(#[from] serde_json::Error),
27
28    /// Invalid configuration or CLI parameter combination.
29    #[error("invalid configuration: {0}")]
30    InvalidConfig(String),
31
32    /// Resumed checkpoint does not match the current invocation or failed verification.
33    #[error("checkpoint mismatch: {0}")]
34    CheckpointMismatch(String),
35
36    /// Input token file or compressed payload is malformed.
37    #[error("invalid codec data: {0}")]
38    InvalidData(String),
39}