Skip to content

Commit

Permalink
Error handling to improve function ergonomics
Browse files Browse the repository at this point in the history
  • Loading branch information
Abeeujah committed Nov 2, 2024
1 parent 1a63fe0 commit 97da96d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions eipw-lint/src/lints/markdown/headings_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ pub struct HeadingsOnly;

impl Lint for HeadingsOnly {
fn lint<'a>(&self, slug: &'a str, ctx: &crate::lints::Context<'a, '_>) -> Result<(), Error> {

Check warning on line 16 in eipw-lint/src/lints/markdown/headings_only.rs

View workflow job for this annotation

GitHub Actions / Check

unused variable: `slug`

Check failure on line 16 in eipw-lint/src/lints/markdown/headings_only.rs

View workflow job for this annotation

GitHub Actions / Rustfmt

unused variable: `slug`

Check warning on line 16 in eipw-lint/src/lints/markdown/headings_only.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

unused variable: `slug`

Check warning on line 16 in eipw-lint/src/lints/markdown/headings_only.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

unused variable: `slug`

Check warning on line 16 in eipw-lint/src/lints/markdown/headings_only.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

unused variable: `slug`

Check warning on line 16 in eipw-lint/src/lints/markdown/headings_only.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

unused variable: `slug`

Check warning on line 16 in eipw-lint/src/lints/markdown/headings_only.rs

View workflow job for this annotation

GitHub Actions / Test Suite (windows-latest)

unused variable: `slug`

Check warning on line 16 in eipw-lint/src/lints/markdown/headings_only.rs

View workflow job for this annotation

GitHub Actions / Test Suite (windows-latest)

unused variable: `slug`

Check warning on line 16 in eipw-lint/src/lints/markdown/headings_only.rs

View workflow job for this annotation

GitHub Actions / Test Suite (windows-latest)

unused variable: `slug`

Check warning on line 16 in eipw-lint/src/lints/markdown/headings_only.rs

View workflow job for this annotation

GitHub Actions / Test Suite (windows-latest)

unused variable: `slug`
let second = ctx
.body()
.descendants()
.nth(1)
.expect("cannot submit an empty proposal")
.data
.borrow()
.to_owned()
.value;
let annotation_type = Level::Error;
let second = match ctx.body().descendants().nth(1) {
Some(el) => el.data.borrow().to_owned().value,
None => return ctx.report(annotation_type.title("Cannot submit an empty proposal")),
};
match second {
NodeValue::Heading(_) => Ok(()),
_ => {
Expand Down

0 comments on commit 97da96d

Please sign in to comment.