1#[cfg(not(target_family = "wasm"))]
6mod model_path;
7
8use std::path::PathBuf;
9
10#[cfg(not(target_family = "wasm"))]
11pub use model_path::{validate_model_directory, validate_model_file};
12
13#[derive(Debug, thiserror::Error)]
17pub enum BackendError {
18 #[error(transparent)]
19 Engine(Box<dyn std::error::Error + Send + Sync>),
20
21 #[error("the backend answered, but the answer is unusable: {0}")]
22 Unusable(String),
23}
24
25impl BackendError {
26 pub fn engine(error: impl std::error::Error + Send + Sync + 'static) -> Self {
27 Self::Engine(Box::new(error))
28 }
29}
30
31#[derive(Debug, thiserror::Error)]
32pub enum ModelError {
33 #[cfg(not(target_family = "wasm"))]
34 #[error(transparent)]
35 Path(#[from] crate::primitives::file_inspection::InspectionError),
36
37 #[error("failed to read the model directory {}", path.display())]
38 ReadDirectory {
39 path: PathBuf,
40 #[source]
41 source: std::io::Error,
42 },
43
44 #[error("model directory {} is missing {file}", directory.display())]
45 Missing {
46 directory: PathBuf,
47 file: &'static str,
48 },
49
50 #[error("failed to read the model file {}", path.display())]
51 Unreadable {
52 path: PathBuf,
53 #[source]
54 source: std::io::Error,
55 },
56
57 #[error("the model file {} is malformed", path.display())]
58 Malformed {
59 path: PathBuf,
60 #[source]
61 source: Box<dyn std::error::Error + Send + Sync>,
62 },
63}