Skip to main content

ic_asset/error/
load_config.rs

1use crate::error::fs::{ReadDirError, ReadToStringError};
2use crate::error::load_rule::LoadRuleError;
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Errors related to loading asset configuration.
7#[derive(Error, Debug)]
8pub enum AssetLoadConfigError {
9    /// Failed to canonicalize the root directory.
10    #[error("root_dir '{0}' is expected to be a canonical path")]
11    InvalidRootDir(PathBuf),
12
13    /// Failed to load a rule from the asset configuration file.
14    #[error("Failed to load rule in {0}")]
15    LoadRuleFailed(PathBuf, #[source] LoadRuleError),
16
17    /// An asset configuration file was not valid JSON5.
18    #[error("Malformed JSON asset config file '{0}'")]
19    MalformedAssetConfigFile(PathBuf, #[source] json5::Error),
20
21    /// both `assets.json` and `assets.json5` files exist in the same directory.
22    #[error("both {} and {} files exist in the same directory (dir = {:?})",
23    crate::asset::config::ASSETS_CONFIG_FILENAME_JSON,
24    crate::asset::config::ASSETS_CONFIG_FILENAME_JSON5,
25    .0.display())]
26    MultipleConfigurationFiles(PathBuf),
27
28    /// Couldn't read a directory when loading asset configuration.
29    #[error(transparent)]
30    ReadDir(#[from] ReadDirError),
31
32    /// Couldn't read a config file.
33    #[error(transparent)]
34    ReadToString(#[from] ReadToStringError),
35}