🐛️ Handle unimported modules properly

helpful error, not panic!

Closes #2422
This commit is contained in:
Emi Simpson 2022-02-24 20:37:16 -05:00
parent b5b26eabc9
commit 4d10c22442
No known key found for this signature in database
GPG key ID: A12F2C2FFDC3D847
7 changed files with 93 additions and 32 deletions

View file

@ -124,12 +124,17 @@ impl<'a> Env<'a> {
})
}
},
None => {
panic!(
"Module {} exists, but is not recorded in dep_idents",
module_name
)
}
None => Err(RuntimeError::ModuleNotImported {
module_name,
imported_modules: self
.dep_idents
.keys()
.filter_map(|module_id| self.module_ids.get_name(*module_id))
.map(|module_name| module_name.as_ref().into())
.collect(),
region,
module_exists: true,
}),
}
}
}
@ -141,6 +146,7 @@ impl<'a> Env<'a> {
.map(|string| string.as_ref().into())
.collect(),
region,
module_exists: false,
}),
}
}