improve code

This commit is contained in:
Seymur Bagirov 2025-03-23 19:22:40 +04:00
parent 90f7755c0c
commit 164c18093b

View File

@ -13,22 +13,19 @@ fn main() -> ExitCode {
Ordering::Equal => { Ordering::Equal => {
let result = run_file(args[1].to_str().unwrap()); let result = run_file(args[1].to_str().unwrap());
if let Err(RunError::FileReadError(e)) = result { return match result {
println!("Couldn't read the file. Reason: {}", e); Err(RunError::FileReadError(e)) => {
return ExitCode::from(1); println!("Couldn't read the file. Reason: {}", e);
} return ExitCode::from(1);
if let Err(RunError::OtherError(e)) = result { }
println!("Error occured. Error: {}", e); Err(RunError::OtherError(e)) => {
return ExitCode::from(75); println!("Error occured. Error: {}", e);
} return ExitCode::from(75);
}
if let Err(RunError::RuntimeError(_r)) = result { Err(RunError::RuntimeError(_)) => ExitCode::from(70),
return ExitCode::from(70); Err(RunError::ParseError) => ExitCode::from(75),
} Ok(_) => ExitCode::SUCCESS,
};
if let Err(RunError::ParseError) = result {
return ExitCode::from(75);
}
} }
Ordering::Less => { Ordering::Less => {
let result = run_prompt(); let result = run_prompt();