feat: register import, types, and values in environment
This commit is contained in:
@@ -45,6 +45,15 @@ pub enum Error {
|
||||
},
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn total(&self) -> usize {
|
||||
match self {
|
||||
Error::List(errors) => errors.len(),
|
||||
_ => 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let miette_handler = MietteHandlerOpts::new()
|
||||
|
||||
@@ -49,15 +49,23 @@ fn main() -> miette::Result<()> {
|
||||
|
||||
let mut project = Project::new(config, project_path);
|
||||
|
||||
if let Err(err) = project.build() {
|
||||
match err {
|
||||
let build_result = project.build();
|
||||
|
||||
for warning in project.warnings {
|
||||
eprintln!("Warning: {:?}", warning)
|
||||
}
|
||||
|
||||
if let Err(err) = build_result {
|
||||
match &err {
|
||||
error::Error::List(errors) => {
|
||||
for error in errors {
|
||||
eprintln!("Error: {:?}", error)
|
||||
}
|
||||
}
|
||||
rest => Err(rest)?,
|
||||
rest => eprintln!("Error: {:?}", rest),
|
||||
}
|
||||
|
||||
miette::bail!("failed: {} errors", err.total());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ pub struct Project {
|
||||
module_types: HashMap<String, tipo::Module>,
|
||||
root: PathBuf,
|
||||
sources: Vec<Source>,
|
||||
warnings: Vec<Warning>,
|
||||
pub warnings: Vec<Warning>,
|
||||
}
|
||||
|
||||
impl Project {
|
||||
|
||||
Reference in New Issue
Block a user