libsvm_rs/error.rs
1//! Error types returned by `libsvm-rs`.
2//!
3//! Loader errors are part of the crate's untrusted-input boundary. Problem
4//! files report line-oriented parse failures with [`SvmError::ParseError`],
5//! model files report structural format failures with
6//! [`SvmError::ModelFormatError`], and filesystem/reader failures use
7//! [`SvmError::Io`]. Training parameter validation uses
8//! [`SvmError::InvalidParameter`].
9
10/// Errors returned by libsvm-rs operations.
11#[derive(Debug, thiserror::Error)]
12pub enum SvmError {
13 /// An SVM parameter failed validation.
14 #[error("invalid parameter: {0}")]
15 InvalidParameter(String),
16
17 /// A parse error occurred while reading a problem or model file.
18 #[error("parse error at line {line}: {message}")]
19 ParseError {
20 /// 1-based line number where the error occurred.
21 line: usize,
22 /// Description of the parse failure.
23 message: String,
24 },
25
26 /// A model file could not be loaded due to format issues.
27 #[error("model format error: {0}")]
28 ModelFormatError(String),
29
30 /// An I/O error occurred.
31 #[error("I/O error: {0}")]
32 Io(#[from] std::io::Error),
33}