Add error handling to the importer

This commit is contained in:
~karx 2021-03-16 12:43:19 -05:00 committed by Yash
parent dab95136c4
commit 804a678f69
No known key found for this signature in database
GPG Key ID: A794DA2529474BA5
1 changed files with 8 additions and 2 deletions

View File

@ -152,8 +152,14 @@ impl Program {
if argument_vec.len() > 1 {
for name in argument_vec[1..].iter() {
let kind = name.chars().nth(0).unwrap();
let name_to_import = name.chars().nth(1).unwrap();
let kind = match name.chars().nth(0) {
Some(content) => content,
None => panic!("SyntaxError: {}: Invalid syntax", arguments)
};
let name_to_import = match name.chars().nth(1) {
Some(content) => content,
None => panic!("SyntaxError: {}: Invalid syntax", arguments)
};
if kind == 'v' {
let key = prog.vars.get(&name_to_import);
match key {