1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, PeftError>;
7
8#[derive(Error, Debug)]
10#[non_exhaustive]
11pub enum PeftError {
12 #[error("invalid configuration: {0}")]
14 InvalidConfig(String),
15
16 #[error("shape mismatch: expected {expected:?}, got {actual:?}")]
18 ShapeMismatch {
19 expected: Vec<usize>,
21 actual: Vec<usize>,
23 },
24
25 #[error("dimension mismatch: {message}")]
27 DimensionMismatch {
28 message: String,
30 },
31
32 #[error("adapter not found: {name}")]
34 AdapterNotFound {
35 name: String,
37 },
38
39 #[error("adapter already exists: {name}")]
41 AdapterExists {
42 name: String,
44 },
45
46 #[error("failed to load weights: {0}")]
48 WeightLoad(String),
49
50 #[error("I/O error: {0}")]
52 Io(String),
53
54 #[error("device mismatch: tensors must be on the same device")]
56 DeviceMismatch,
57
58 #[error("candle error: {0}")]
60 Candle(#[from] candle_core::Error),
61}