1use crate::Instruction;
2use crate::ice;
3
4use std::io;
5use std::path::PathBuf;
6use std::sync::Arc;
7
8#[derive(Debug, Clone, thiserror::Error)]
10pub enum Error {
11 #[error("no matching widget was found for the selector: {selector}")]
13 SelectorNotFound {
14 selector: String,
16 },
17 #[error("the matching target is not visible: {target:?}")]
19 TargetNotVisible {
20 target: Arc<dyn std::fmt::Debug + Send + Sync>,
22 },
23 #[error("an IO operation failed: {0}")]
25 IOFailed(Arc<io::Error>),
26 #[error("the decoding of some PNG image failed: {0}")]
28 PngDecodingFailed(Arc<png::DecodingError>),
29 #[error("the encoding of some PNG image failed: {0}")]
31 PngEncodingFailed(Arc<png::EncodingError>),
32 #[error("the ice test ({file}) is invalid: {error}")]
34 IceParsingFailed {
35 file: PathBuf,
37 error: ice::ParseError,
39 },
40 #[error("the ice test ({file}) failed")]
42 IceTestingFailed {
43 file: PathBuf,
45 instruction: Instruction,
47 },
48 #[error(
50 "the preset \"{name}\" does not exist (available presets: {available:?})"
51 )]
52 PresetNotFound {
53 name: String,
55 available: Vec<String>,
57 },
58}
59
60impl From<io::Error> for Error {
61 fn from(error: io::Error) -> Self {
62 Self::IOFailed(Arc::new(error))
63 }
64}
65
66impl From<png::DecodingError> for Error {
67 fn from(error: png::DecodingError) -> Self {
68 Self::PngDecodingFailed(Arc::new(error))
69 }
70}
71
72impl From<png::EncodingError> for Error {
73 fn from(error: png::EncodingError) -> Self {
74 Self::PngEncodingFailed(Arc::new(error))
75 }
76}