outline/error.rs
1use std::path::PathBuf;
2
3use thiserror::Error;
4
5/// Result type alias for operations that may fail with [`OutlineError`].
6pub type OutlineResult<T> = std::result::Result<T, OutlineError>;
7
8/// Error types that can occur during outline processing.
9///
10/// This enum covers errors from model inference, image I/O, mask processing,
11/// and vectorization operations.
12#[derive(Debug, Error)]
13pub enum OutlineError {
14 /// ONNX Runtime inference error.
15 #[error("ONNX Runtime error: {0}")]
16 Ort(#[from] ort::Error),
17 /// Image loading, decoding, or encoding error.
18 #[error("Image processing failed: {0}")]
19 Image(#[from] image::ImageError),
20 /// File system I/O error.
21 #[error(transparent)]
22 Io(#[from] std::io::Error),
23 /// Tensor shape mismatch or invalid dimensions.
24 #[error("Invalid tensor shape: {0}")]
25 Shape(#[from] ndarray::ShapeError),
26 /// Vectorization or tracing operation failed.
27 #[error("Tracing failed: {0}")]
28 Trace(String),
29 /// Alpha matte dimensions do not match the source image.
30 #[error("Alpha matte size {found:?} does not match source image size {expected:?}")]
31 AlphaMismatch {
32 /// Expected dimensions (width, height).
33 expected: (u32, u32),
34 /// Actual dimensions (width, height).
35 found: (u32, u32),
36 },
37 /// Model file not found at the specified path.
38 #[error("Model file not found: {}", path.display())]
39 ModelNotFound {
40 /// The path that was searched.
41 path: PathBuf,
42 },
43}