Skip to content

Commit

Permalink
fix: maded panic messages more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
JarKz committed Apr 5, 2024
1 parent e50fdd5 commit 363deb0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ impl Keyword {
let float_exists = float.is_some() as u8;
let str_exists = str.is_some() as u8;

// EXPLANATION: if at least two values is exists then we stop execution.
// EXPLANATION: if at least two types of value is exists then we stop execution.
if int_exists + float_exists + str_exists > 1 {
panic!("The option have more than one type together! Please open an issue!")
panic!("Expected single value type, but received more than one! Please open an issue with the information: Option {{ option: {option}, int: {int:?}, float: {float:?}, str: {str:?}, set: {set} }}!")
}

let value = match (int, float, str) {
(Some(int), _, _) => OptionValue::Int(int),
(_, Some(float), _) => OptionValue::Float(float),
(_, _, Some(str)) => OptionValue::String(str),
_ => panic!("Unrecognized option value! Please open issue!"),
(int, float, str) => panic!("Expected either an 'int', a 'float' or a 'str', but none of them is not received! Please open an issue with the information: Option {{ option: {option}, int: {int:?}, float: {float:?}, str: {str:?}, set: {set} }}!"),
};

Keyword { option, value, set }
Expand Down

0 comments on commit 363deb0

Please sign in to comment.