feat(xatu): reject files with parse errors #72

Merged
alexion merged 1 commits from feat/xatu-fatal-parse-errors into main 2026-09-18 21:14:45 -04:00
2 changed files with 12 additions and 0 deletions
Showing only changes of commit 113018a62c - Show all commits

View File

@@ -10,6 +10,7 @@ pub trait ResultExt<T> {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Code {
InvalidArgument,
FailedPrecondition,
NotFound,
PermissionDenied,
Internal,
@@ -39,6 +40,10 @@ impl Status {
Self::new(Code::InvalidArgument, message)
}
pub fn failed_precondition(message: impl Into<String>) -> Self {
Self::new(Code::FailedPrecondition, message)
}
pub fn permission_denied(message: impl Into<String>) -> Self {
Self::new(Code::PermissionDenied, message)
}

View File

@@ -13,6 +13,13 @@ pub fn run(files: Vec<SourceFile>) -> status::Result<()> {
let file = store.get(file_id);
let parsed = parser::parse_file(file_id, &file.source);
if !parsed.errors.is_empty() {
return Err(status::Status::failed_precondition(format!(
"failed to parse {}",
file.path.display()
)));
}
for diagnostic in rules::run_rules(&parsed) {
println!(
"{}:{}..{}: {}: {}",