From 89193143f90e1b8cbb91445d14942fa39509acbb Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 9 Jan 2023 23:12:52 +0100 Subject: implemented more Error (dumb) --- src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 17ad6b9..eb845d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,10 +6,11 @@ pub mod db; pub mod error; pub mod files; -use std::{io::{Error, ErrorKind}, path::Path}; +use std::path::Path; pub use apis::*; pub use commands::*; +use error::{MLE, ErrorType, MLError}; #[derive(Debug, Clone, PartialEq, Eq)] pub enum Modloader { @@ -18,18 +19,18 @@ pub enum Modloader { } impl Modloader { - fn stringify(&self) -> String { + fn to_string(&self) -> String { match self { Modloader::Fabric => String::from("fabric"), Modloader::Forge => String::from("forge"), } } - fn from(string: &str) -> Result> { + fn from(string: &str) -> MLE { match string { "forge" => Ok(Modloader::Forge), "fabric" => Ok(Modloader::Fabric), - _ => Err(Box::new(Error::new(ErrorKind::InvalidData, "UNKNOWN_MODLOADER"))) + _ => Err(MLError::new(ErrorType::ArgumentError, "UNKNOWN_MODLOADER")) } } } -- cgit v1.2.3