Skip to main content

path_offset/
error.rs

1//! Defines the error types used throughout the library.
2
3use lyon::extra::parser::ParseError;
4use thiserror::Error;
5
6/// A convenient result type alias for operations within this crate.
7pub type Result<T, E = PathError> = std::result::Result<T, E>;
8
9/// Represents all possible errors that can occur within the path processing modules.
10#[derive(Error, Debug)]
11pub enum PathError {
12    /// An error that occurred while parsing an SVG path data string.
13    /// This variant automatically converts from `lyon::extra::parser::ParseError`.
14    #[error("Failed to parse SVG path data: {0}")]
15    Parse(#[from] ParseError),
16
17    /// An error indicating that fitting a curve to a set of points failed.
18    #[error("Failed to fit a curve to the points")]
19    FitCurve,
20
21    /// An error indicating that cleaning a path (e.g., removing self-intersections) failed.
22    #[error("Failed to clean the path")]
23    CleanPath,
24
25    /// An I/O error occurred.
26    /// This is useful for operations that might read path data from files.
27    #[error("I/O error: {0}")]
28    Io(#[from] std::io::Error),
29}