diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 5c2399a..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,2 +0,0 @@ -[target.'cfg(all())'] -runner = "./.cargo/runner.sh" diff --git a/.cargo/runner.sh b/.cargo/runner.sh deleted file mode 100755 index 0f3076e..0000000 --- a/.cargo/runner.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -cd ../rte && exec "$@" diff --git a/src/config.rs b/src/config.rs index 1534293..62bb14a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -61,6 +61,6 @@ size_z = 64 .read_to_string(&mut config_data) .expect("Failed to read config file"); - Ok(toml::from_str(&config_data).expect("Failed to deserialize config.toml")) + Ok(toml::from_str(&config_data)?) } } diff --git a/src/error.rs b/src/error.rs index d50c71f..23075d9 100644 --- a/src/error.rs +++ b/src/error.rs @@ -13,6 +13,7 @@ pub enum AppError { TryFromIntError(TryFromIntError), RhaiError(Box), MutexPoisoned(String), + DeserializerError(toml::de::Error), InvalidWorldFile, // InvalidExtensionVersion, } @@ -27,6 +28,7 @@ impl fmt::Display for AppError { AppError::TryFromIntError(err) => write!(f, "Integer conversion error: {}", err), AppError::RhaiError(err) => write!(f, "Rhai compilation error: {}", err), AppError::MutexPoisoned(err) => write!(f, "Poisoned mutex: {}", err), + AppError::DeserializerError(err) => write!(f, "Config Deserializer Failed: {}", err), AppError::InvalidWorldFile => write!(f, "Invalid world file"), // AppError::InvalidExtensionVersion => write!(f, "Invalid extension version"), } @@ -74,3 +76,9 @@ impl From> for AppError { AppError::MutexPoisoned(err.to_string()) } } + +impl From for AppError { + fn from(err: toml::de::Error) -> Self { + AppError::DeserializerError(err) + } +}