serde_hkx_features/
error.rs1use std::{io, path::PathBuf};
3
4#[allow(clippy::enum_variant_names)]
6#[derive(Debug, snafu::Snafu)]
7#[snafu(visibility(pub))]
8pub enum Error {
9 #[cfg(not(feature = "extra_fmt"))]
11 #[snafu(display("The only supported extension is `.hkx` or `.xml`. But this path is neither: {}.", path.display()))]
12 UnsupportedExtensionPath { path: PathBuf },
13 #[cfg(feature = "extra_fmt")]
14 #[snafu(display("The only supported extension is `.hkx`, `.xml`, `.json`, `yaml`. But this path is neither: {}.", path.display()))]
16 UnsupportedExtensionPath { path: PathBuf },
17
18 #[cfg(not(feature = "extra_fmt"))]
20 UnsupportedExtension { ext: String },
21 #[cfg(feature = "extra_fmt")]
22 UnsupportedExtension { ext: String },
24
25 #[snafu(display("This path has a missing extension.: {}.", path.display()))]
27 MissingExtension { path: PathBuf },
28
29 #[snafu(display("{source}: {}", path.display()))]
31 FailedReadFile { source: io::Error, path: PathBuf },
32
33 InvalidStdout,
35
36 #[snafu(display("Failed to convert the following paths (error count: {}/{total_files}) in {}: \n{err_paths:#?}", err_paths.len(), path.display()))]
38 FailedConvertFiles {
39 path: PathBuf,
40 total_files: usize,
41 err_paths: Vec<PathBuf>,
42 },
43
44 #[snafu(display("Failed to reproduce (-: input / +: output) {}: \n{diff}", path.display()))]
46 FailedReproduceFile { path: PathBuf, diff: String },
47
48 #[snafu(display("Failed to reproduce the following paths (error count: {}/{total_files}) in {}: \n{err_paths:#?}", err_paths.len(), path.display()))]
50 FailedReproduceFiles {
51 path: PathBuf,
52 total_files: usize,
53 err_paths: Vec<PathBuf>,
54 },
55
56 #[snafu(display("{}:\n {source}", input.display()))]
58 SerError {
59 input: PathBuf,
60 source: serde_hkx::errors::ser::Error,
61 },
62
63 #[snafu(display("{}:\n {source}", input.display()))]
65 DeError {
66 input: PathBuf,
67 source: serde_hkx::errors::de::Error,
68 },
69
70 #[snafu(transparent)]
72 IoError { source: std::io::Error },
73
74 #[snafu(transparent)]
76 StripPrefixError { source: std::path::StripPrefixError },
77
78 #[snafu(transparent)]
80 JwalkError { source: jwalk::Error },
81
82 #[cfg(feature = "tracing")]
84 #[snafu(transparent)]
85 TracingError {
86 source: tracing::subscriber::SetGlobalDefaultError,
87 },
88
89 #[snafu(transparent)]
90 FailedThreadJoin { source: tokio::task::JoinError },
91
92 #[snafu(display("Failed to parse key '{key}' into usize"))]
94 KeyParse {
95 key: String,
96 source: std::num::ParseIntError,
97 },
98
99 #[cfg(feature = "extra_fmt")]
101 #[snafu(transparent)]
102 ExtraSerdeError {
103 source: crate::serde_extra::error::ExtraSerdeError,
104 },
105
106 #[cfg(feature = "json_schema")]
108 #[snafu(transparent)]
109 JsonError { source: simd_json::Error },
110}
111
112pub type Result<T, E = Error> = core::result::Result<T, E>;