1pub use crate::version::Edition;
2use std::path::PathBuf;
3use thiserror::Error; #[derive(Error, Debug)]
7pub enum McDataError {
8 #[error("Version string '{0}' is invalid or unsupported")]
10 InvalidVersion(String),
11
12 #[error("Version '{mc_version}' (major: {major_version}) not found for edition {edition:?}")]
13 VersionNotFound {
14 mc_version: String,
15 major_version: String,
16 edition: Edition,
17 },
18
19 #[error(
21 "Data key '{data_key}' not found in dataPaths.json for version {mc_version} ({edition:?})"
22 )]
23 DataPathNotFound {
24 mc_version: String, edition: Edition,
26 data_key: String, },
28
29 #[error("Data file not found for key '{data_key}' at expected path pattern: {path:?}")]
30 DataFileNotFound { data_key: String, path: PathBuf },
31
32 #[error("I/O error accessing path {path:?}: {source}")]
33 IoError {
34 path: PathBuf,
35 #[source]
36 source: std::io::Error,
37 },
38
39 #[error("Failed to parse JSON file {path:?}: {source}")]
40 JsonParseError {
41 path: PathBuf,
42 #[source]
43 source: serde_json::Error,
44 },
45
46 #[error("Could not determine a valid cache directory for application data")]
48 CacheDirNotFound,
49
50 #[error("Failed to download minecraft-data: {0}")]
51 DownloadError(String), #[error("Failed to process downloaded archive: {0}")]
54 ArchiveError(String), #[error("Failed to verify data after download/extraction in {0:?}")]
57 DownloadVerificationFailed(PathBuf), #[error("Internal error: {0}")]
61 Internal(String), #[error("Cached operation failed previously: {0}")]
64 CachedError(String), }