aboutsummaryrefslogtreecommitdiff
path: root/libs/nres/src/error.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2025-06-15 01:42:55 +0300
committerGitHub <noreply@github.com>2025-06-15 01:42:55 +0300
commit2273fd4263b91a877b043dacf4b9311c98d3bcbb (patch)
treee2502636adc081c2a71179402774fa90d5be8a9d /libs/nres/src/error.rs
parentd4f104cf5ebca5acf4379e5108c635e008c0c82f (diff)
parentd274602104892e181205725c6b9c9082a9669942 (diff)
downloadfparkan-2273fd4263b91a877b043dacf4b9311c98d3bcbb.tar.xz
fparkan-2273fd4263b91a877b043dacf4b9311c98d3bcbb.zip
Merge pull request #7 from valentineus/nres
Обновление структуры проекта
Diffstat (limited to 'libs/nres/src/error.rs')
-rw-r--r--libs/nres/src/error.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/libs/nres/src/error.rs b/libs/nres/src/error.rs
new file mode 100644
index 0000000..440ab06
--- /dev/null
+++ b/libs/nres/src/error.rs
@@ -0,0 +1,45 @@
+extern crate miette;
+extern crate thiserror;
+
+use miette::Diagnostic;
+use thiserror::Error;
+
+#[derive(Error, Diagnostic, Debug)]
+pub enum ConverterError {
+ #[error("error converting an value")]
+ #[diagnostic(code(libnres::infallible))]
+ Infallible(#[from] std::convert::Infallible),
+
+ #[error("error converting an value")]
+ #[diagnostic(code(libnres::try_from_int_error))]
+ TryFromIntError(#[from] std::num::TryFromIntError),
+}
+
+#[derive(Error, Diagnostic, Debug)]
+pub enum ReaderError {
+ #[error(transparent)]
+ #[diagnostic(code(libnres::convert_error))]
+ ConvertValue(#[from] ConverterError),
+
+ #[error("incorrect header format")]
+ #[diagnostic(code(libnres::list_type_error))]
+ IncorrectHeader,
+
+ #[error("incorrect file size (expected {expected:?} bytes, received {received:?} bytes)")]
+ #[diagnostic(code(libnres::file_size_error))]
+ IncorrectSizeFile { expected: u32, received: u32 },
+
+ #[error(
+ "incorrect size of the file list (not a multiple of {expected:?}, received {received:?})"
+ )]
+ #[diagnostic(code(libnres::list_size_error))]
+ IncorrectSizeList { expected: u32, received: u32 },
+
+ #[error("resource file reading error")]
+ #[diagnostic(code(libnres::io_error))]
+ ReadFile(#[from] std::io::Error),
+
+ #[error("file is too small (must be at least {expected:?} bytes, received {received:?} byte)")]
+ #[diagnostic(code(libnres::file_size_error))]
+ SmallFile { expected: u32, received: u32 },
+}