Skip to content

Using result type to reflect scanning error#28

Merged
delfanbaum merged 1 commit intodelfanbaum:mainfrom
athanclark:main
Sep 7, 2025
Merged

Using result type to reflect scanning error#28
delfanbaum merged 1 commit intodelfanbaum:mainfrom
athanclark:main

Conversation

@athanclark
Copy link
Contributor

This system already has a ScannerError that looks like it was built to be extended - I just added a ScannerError::String data constructor, and passed the call to error!(...) into ScannerError::String(format!(...)) to allow end-users the ability to decide how they want to handle the error. I also removed the process kill line.

@delfanbaum
Copy link
Owner

Thanks for catching this! The CI is failing because of an issue with a feature dependency, so given that I'm about to fix that in the release I'm prepping, we can just merge this in and I'll do what little fiddling I'm going to do on the (rebased) release branch.

Just FYI, one crate-idiomatic thing I'm going to change is to make the error less generic so that we can match on it if that's ever needed -- just to make it align more closely with the other error structs in the repo.

The one code feedback thing I would note is that since that function is just a big match, you don't need the explicit return (since the other arms are returning, essentially Ok(token), so that line could instead be written:

_ => Err(ScannerError::String(format!("Invalid headling level: line {}", self.line)))

In any case, thanks for the contribution!

@delfanbaum delfanbaum merged commit 3098670 into delfanbaum:main Sep 7, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants