Repository navigation
fix: include payload in Error Display impl (#426) - #428
Merged
Merged
Conversation
The Display impl for Error printed only the variant name and dropped the
String payload for MenuExists, WindowCreate and UpdateFailed. Detailed
messages (e.g. the buffer-size explanation from check_buffer_size) were
therefore lost via to_string(), `{}`, and Box<dyn Error> reporting, and
only visible through {:?}.
Include the payload in Display so the detail reaches error reporting.
Closes emoon#426
Owner
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #426.
The
Displayimpl forErrorprinted only the variant name and discarded theStringpayload:So a detailed message — for example the buffer-size explanation built in
check_buffer_size(src/lib.rs) — never reachederr.to_string(),println!("{}", err), orBox<dyn Error>reporting; it was only visible via{:?}.Fix
Bind and include the payload in
Display:Debugis left unchanged (it already includes the payload).Tests
Added a unit test asserting
to_string()includes the payload for each variant.Verified RED→GREEN: with the old
Display, the test fails (left: "Failed to Update",right: "Failed to Update: buffer too small"); with the fix it passes.Validation (real results)
cargo test --lib display_includes_payload: passes.cargo fmt --check: clean.