sticknodes_rs/
error.rs

1use core2::io;
2use thiserror::Error;
3extern crate alloc;
4use alloc::string::String;
5
6#[derive(Error, Debug)]
7pub enum LibraryError {
8    #[error("Error: {0}")]
9    AnyString(String),
10
11    #[error("Stick Nodes version {0} is not supported. Please check if an update to this library is available.")]
12    UnsupportedVersion(i32),
13
14    #[error("Although Stick Nodes version {0} is supported, Stick Nodes build {1} is not supported. Please check if an update to this library is available.")]
15    UnsupportedBuild(i32, i32),
16
17    #[error("Stickfigure file error: {0}")]
18    StickfigureError(#[from] StickfigureError),
19}
20
21#[derive(Error, Debug)]
22pub enum StickfigureError {
23    #[error("I/O error: {0}")]
24    Io(io::Error),
25
26    #[error("Invalid stickfigure header: {0}")]
27    InvalidHeader(String),
28
29    #[error("Error reading node: {0}")]
30    NodeError(String),
31
32    #[error("Cannot add {0} node(s). Current node count is {1}. Node limit is {2}.")]
33    NodeLimitError(usize, usize, usize),
34
35    #[error("Draw order index {0} does not exist. {1}")]
36    InvalidDrawIndex(i32, String),
37
38    #[error("Node at draw order index {0} is already an anchor node. {1}")]
39    NodeIsAlreadyAnchor(i32, String),
40
41    #[error("The following draw order indices do not exist: {0} {1}")]
42    InvalidDrawIndices(String, String),
43
44    #[error("Draw order index {0} is already occupied. {1}")]
45    OccupiedDrawIndex(i32, String),
46}
47
48#[derive(Error, Debug)]
49pub enum ColorError {
50    #[error("{0} is not a valid hex string. The value of the following part of the hex string could not be parsed: {1}")]
51    InvalidHexStringValue(String, String),
52
53    #[error("{0} is not a valid hex string. It is either missing a starting \"#\", is not a valid length")]
54    InvalidHexStringLength(String, usize),
55
56    #[error("{0} is not a valid hex string. It is either missing a starting \"#\", is not a valid length")]
57    InvalidHexStringPrefix(String),
58
59    #[error("{0} is not a valid hex string.")]
60    InvalidHexString(String),
61
62    #[error("Hex string is empty.")]
63    EmptyHexString(),
64
65    #[error("Trimmed hex string is empty. Was your hex string just \"#\"s?")]
66    EmptyTrimmedHexString(),
67}