concision_params/
error.rs

1/*
2    Appellation: error <module>
3    Contrib: @FL03
4*/
5//! This module defines error types and handling mechanisms for the `params` crate.
6//!
7
8/// A type alias for a [`Result`](core::result::Result) which uses the [`ParamsError`] type
9pub type Result<T = ()> = core::result::Result<T, ParamsError>;
10
11/// the [`ParamsError`] enumerates various errors that can occur within the parameters of a
12/// neural network.
13#[derive(Debug, thiserror::Error)]
14pub enum ParamsError {
15    #[error("Invalid biases")]
16    InvalidBiases,
17    #[error("Invalid weights")]
18    InvalidWeights,
19    #[error(
20        "Unable to complete the operation due to a mismatch between shapes: expected {expected:?}, found {found:?}"
21    )]
22    MismatchedShapes {
23        expected: &'static [usize],
24        found: &'static [usize],
25    },
26    #[error("An invalid tensor of length {0} was provided")]
27    InvalidLength(usize),
28    #[error("Invalid output shape")]
29    InvalidOutputShape,
30    #[error("Invalid parameter: {0}")]
31    InvalidParameter(String),
32    #[error("Invalid parameter type")]
33    InvalidParameterType,
34    #[error("Invalid parameter value")]
35    InvalidParameterValue,
36    #[error("Must be non-empty")]
37    EmptyInput,
38    #[error(transparent)]
39    ShapeError(#[from] ndarray::ShapeError),
40}