Skip to content

feat: Improve errors from try_deserialize#695

Merged
epage merged 2 commits into
rust-cli:mainfrom
barskern:feat/improve-errors
Sep 30, 2025
Merged

feat: Improve errors from try_deserialize#695
epage merged 2 commits into
rust-cli:mainfrom
barskern:feat/improve-errors

Conversation

@barskern
Copy link
Copy Markdown
Contributor

@barskern barskern commented Sep 23, 2025

Enables user code to handle missing and invalid fields after calling try_deserialize instead of having to match and search in the string returned in ConfigError::Message.

Personally I deem the String::leak call safe for my usage, as I would expect to terminate my program on configuration errors anyhow, however we could certainly also change the expected field to be a Cow<str> or similar to handle both &'static str and String elegantly.

Part of #532

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 17951967632

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 17 of 23 (73.91%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.3%) to 65.182%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/error.rs 17 23 73.91%
Files with Coverage Reduction New Missed Lines %
src/error.rs 4 73.58%
Totals Coverage Status
Change from base Build 17860294716: 0.3%
Covered Lines: 966
Relevant Lines: 1482

💛 - Coveralls

Comment thread src/error.rs
@epage
Copy link
Copy Markdown
Contributor

epage commented Sep 29, 2025

Looks like some more test cases need updating

@barskern
Copy link
Copy Markdown
Contributor Author

Looks like some more test cases need updating

Yeah, I didn't run with --all-features. While going through it I also changed some of the places were we can now rather match on the enum than search in the string, to show that it should return a proper variant.

@epage
Copy link
Copy Markdown
Contributor

epage commented Sep 30, 2025

Thanks!

@epage epage merged commit fd203fb into rust-cli:main Sep 30, 2025
15 checks passed
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.

3 participants