asset_container/
error.rs

1use std::path::PathBuf;
2
3/// Errors that can occur when processing assets.
4#[derive(thiserror::Error, Clone, Debug)]
5#[non_exhaustive]
6pub enum Error {
7  /// Asset not found at the specified path.
8  #[error("File not found {0}")]
9  FileNotFound(String),
10
11  /// Could not read asset at the specified location.
12  #[error("Error opening file {}: {1}", .0.display())]
13  FileOpen(PathBuf, String),
14
15  /// Could not fetch remote asset.
16  #[error("Error fetching file {0}: {1}")]
17  RemoteFetch(String, String),
18
19  /// Could not load file.
20  #[error("Could not read file {0}")]
21  LoadError(String),
22
23  /// Could not fetch directory as bytes.
24  #[error("Can not fetch directory bytes {}", .0.display())]
25  IsDirectory(PathBuf),
26
27  /// The location of the asset was in a format the Asset couldn't parse.
28  #[error("Could not parse location format: {0}")]
29  Parse(String),
30}
31
32impl From<std::io::Error> for Error {
33  fn from(e: std::io::Error) -> Self {
34    Self::LoadError(e.to_string())
35  }
36}