actually get the error by code from ERRORS and not just returning the same for every error code

This commit is contained in:
Sebastian Moser
2023-03-17 07:13:08 +01:00
parent 68ef9286fe
commit e4eb8d25f7

View File

@@ -95,13 +95,19 @@ impl MizeError {
pub fn new(code: u32) -> MizeError { pub fn new(code: u32) -> MizeError {
let caller_location = std::panic::Location::caller(); let caller_location = std::panic::Location::caller();
MizeError { if let Some(err_ref) = ERRORS.get(&code) {
category: "error with error system".to_string(), let mut err = err_ref.clone();
code: 114, err.code_location = Some(caller_location.into());
message: "The error with code {} was not found in the Errors that where imported from the errors.toml file at build time.".to_string(), return err;
extra_msg: None, } else {
caused_by_msg: None, return MizeError {
code_location: Some(caller_location.into()), category: "error with error system".to_string(),
code: 114,
message: format!("The error with code {} was not found in the Errors that where imported from the errors.toml file at build time.", code),
extra_msg: None,
caused_by_msg: None,
code_location: Some(caller_location.into()),
};
} }
} }
@@ -187,3 +193,5 @@ impl From<serde_json::Error> for MizeError {
} }