aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2021-11-06 22:25:23 +0100
committerDaniel Schadt <kingdread@gmx.de>2021-11-06 22:25:23 +0100
commit834a2d4f8a7dbd0e9eb14573c4340eb41af04738 (patch)
treebebd06cc13104fb8e77dc313f2f2ee862eb94a32 /src/error.rs
downloadmodderbaas-834a2d4f8a7dbd0e9eb14573c4340eb41af04738.tar.gz
modderbaas-834a2d4f8a7dbd0e9eb14573c4340eb41af04738.tar.bz2
modderbaas-834a2d4f8a7dbd0e9eb14573c4340eb41af04738.zip
Initial commit
This is the inital commit of a somewhat working version.
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..d60fabd
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,39 @@
+use std::path::PathBuf;
+
+use thiserror::Error;
+
+#[derive(Error, Debug)]
+pub enum Error {
+ #[error("invalid mod id '{0}'")]
+ InvalidModId(String),
+ #[error("underlying HTTP error")]
+ UreqError(#[from] ureq::Error),
+ #[error("underlying I/O error")]
+ IoError(#[from] std::io::Error),
+ #[error("the website returned unexpected data")]
+ InvalidScrape,
+ #[error("'{0}' is not a valid mod directory")]
+ InvalidModDir(PathBuf),
+ #[error("filesystem error")]
+ FsExtraError(#[from] fs_extra::error::Error),
+ #[error("ZIP error")]
+ ZipError(#[from] zip::result::ZipError),
+ #[error("the downloaded file was empty")]
+ EmptyArchive,
+ #[error("'{0}' is not a valid game directory")]
+ InvalidGameDir(PathBuf),
+ #[error("'{0}' is not a valid world directory")]
+ InvalidWorldDir(PathBuf),
+ #[error("'{0}' is not a valid modpack directory")]
+ InvalidModpackDir(PathBuf),
+ #[error("the world has no game ID set")]
+ NoGameSet,
+ #[error("'{0}' does not represent a valid mod source")]
+ InvalidSourceSpec(String),
+ #[error("invalid URL")]
+ UrlError(#[from] url::ParseError),
+ #[error("the mod ID '{0}' does not point to a single mod")]
+ AmbiguousModId(String),
+}
+
+pub type Result<T, E = Error> = std::result::Result<T, E>;