Skip to main content

xq_vision/
error.rs

1use thiserror::Error;
2
3use crate::session::ExecutionProvider;
4
5pub type Result<T> = std::result::Result<T, XqVisionError>;
6
7#[derive(Debug, Error)]
8pub enum XqVisionError {
9    #[error("missing {role} model")]
10    MissingModel { role: &'static str },
11
12    #[error("invalid image size {width}x{height}; expected at least {min_width}x{min_height}")]
13    ImageTooSmall { width: u32, height: u32, min_width: u32, min_height: u32 },
14
15    #[error("invalid geometry: {0}")]
16    InvalidGeometry(&'static str),
17
18    #[error("singular {0} transform")]
19    SingularTransform(&'static str),
20
21    #[error("{model} output shape mismatch; expected {expected}, got {actual:?}")]
22    OutputShape { model: &'static str, expected: &'static str, actual: Vec<usize> },
23
24    #[error("{model} output is not contiguous in memory")]
25    NonContiguousOutput { model: &'static str },
26
27    #[error("invalid piece class index {0}")]
28    InvalidPieceIndex(u8),
29
30    #[error("invalid board recognition result")]
31    InvalidBoard,
32
33    #[error("execution provider {provider:?} requires an enabled Cargo feature or supported platform")]
34    UnsupportedProvider { provider: ExecutionProvider },
35
36    #[error("i/o error: {0}")]
37    Io(#[from] std::io::Error),
38
39    #[error("image error: {0}")]
40    Image(#[from] image::ImageError),
41
42    #[error("onnx runtime error: {0}")]
43    Ort(#[from] ort::Error),
44}