Skip to content

Commit d030e99

Browse files
authored
Merge pull request #348 from lqd/table-errors
Improve duplicate table errors
2 parents 0d0f95d + aa602cd commit d030e99

File tree

1 file changed

+14
-4
lines changed
  • crates/rust-project-goals/src

1 file changed

+14
-4
lines changed

crates/rust-project-goals/src/goal.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,20 @@ fn goal_plan(
537537
plan_items,
538538
}))
539539
}
540-
_ => anyhow::bail!(
541-
"multiple goal tables found in section `{}`",
542-
section.title.render()
543-
),
540+
thats_too_many => {
541+
let mut table_error = Vec::new();
542+
for (idx, table) in section.tables.iter().enumerate() {
543+
let header: Vec<_> = table.header.iter().map(|h| h.to_string()).collect();
544+
table_error.push(format!("{}: {:?}", idx + 1, header.join(", ")));
545+
}
546+
547+
anyhow::bail!(
548+
"markdown parsing unexpectedly encountered multiple ({}) goal tables in section `{}`:\n{}",
549+
thats_too_many,
550+
section.title.render(),
551+
table_error.join("\n"),
552+
)
553+
}
544554
}
545555
}
546556

0 commit comments

Comments
 (0)