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

@ -209,6 +209,45 @@ pub fn type_problem<'b>(
severity,
})
}
IngestedFileBadUtf8(file_path, utf8_err) => {
let stack = [
alloc.concat([
alloc.reflow("Failed to load "),
alloc.text(format!("{:?}", file_path)),
alloc.reflow(" as Str:"),
]),
alloc.text(format!("{}", utf8_err)),
];
Some(Report {
title: "INVALID UTF-8".to_string(),
filename,
doc: alloc.stack(stack),
severity,
})
}
IngestedFileUnsupportedType(file_path, typ) => {
let stack = [
alloc.concat([
alloc.text(format!("{:?}", file_path)),
alloc.reflow(" is annotated to be a "),
alloc.inline_type_block(error_type_to_doc(alloc, typ)),
alloc.reflow("."),
]),
alloc.concat([
alloc.reflow("Ingested files can only be of type "),
alloc.type_str("List U8"),
alloc.reflow(" or "),
alloc.type_str("Str"),
alloc.reflow("."),
]),
];
Some(Report {
title: "INVALID TYPE FOR INGESTED FILE".to_string(),
filename,
doc: alloc.stack(stack),
severity,
})
}
}
}