add proper error messages for ingested files

This commit is contained in:
Brendan Hansknecht 2023-04-07 18:16:43 -07:00
parent 62fcc71be3
commit e5b88366fe
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
5 changed files with 86 additions and 25 deletions

View file

@ -1,4 +1,6 @@
//! Provides types to describe problems that can occur during solving.
use std::{path::Path, str::Utf8Error};
use roc_can::expected::{Expected, PExpected};
use roc_module::{ident::Lowercase, symbol::Symbol};
use roc_problem::{can::CycleEntry, Severity};
@ -29,6 +31,8 @@ pub enum TypeError {
expected_opaque: Symbol,
found_opaque: Symbol,
},
IngestedFileBadUtf8(Box<Path>, Utf8Error),
IngestedFileUnsupportedType(Box<Path>, ErrorType),
}
impl TypeError {
@ -48,6 +52,8 @@ impl TypeError {
TypeError::Exhaustive(exhtv) => exhtv.severity(),
TypeError::StructuralSpecialization { .. } => RuntimeError,
TypeError::WrongSpecialization { .. } => RuntimeError,
TypeError::IngestedFileBadUtf8(..) => Fatal,
TypeError::IngestedFileUnsupportedType(..) => Fatal,
}
}
}