Skip to main content

nam_rs/
error.rs

1use thiserror::Error;
2
3/// Errors produced when loading or building a NAM model.
4#[derive(Debug, Error)]
5pub enum Error {
6    /// The `.nam` JSON could not be parsed.
7    #[error("failed to parse .nam JSON: {0}")]
8    Json(#[from] serde_json::Error),
9
10    /// The file was read but its contents are not a valid/supported model.
11    #[error("failed to read .nam file: {0}")]
12    Io(#[from] std::io::Error),
13
14    /// The model's `architecture` field is not one this crate can run.
15    #[error("unsupported model architecture: {0:?}")]
16    UnsupportedArchitecture(String),
17
18    /// A layer's `activation` field names a function this crate does not implement.
19    #[error("unsupported activation function: {0:?}")]
20    UnsupportedActivation(String),
21
22    /// The flat `weights` array did not contain the number of values the
23    /// `config` implies (corrupt file, or a config/weights mismatch).
24    #[error("weight count mismatch: config implies {expected} weights, file has {found}")]
25    WeightCountMismatch { expected: usize, found: usize },
26}