Repository navigation
Keep the code and help of espflash errors - #1148
Open
SergioGasquez wants to merge 3 commits into
Open
SergioGasquez wants to merge 3 commits into
SergioGasquez wants to merge 3 commits into
Conversation
SergioGasquez
force-pushed
the
fix/keep-diagnostic-help
branch
from
November 20, 2026 14:09
5092342 to
6d34af4
Compare
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.
Description
Fixes #1136.
Several CLI paths converted espflash's own errors, which implement
miette::Diagnostic, with.into_diagnostic(). That wraps them as plainstd::error::Errors and drops theircode(...)andhelp(...), so users only saw the one-line message. They're now converted with.into()/?, which go throughFrom<E: Diagnostic> for Reportand keep both.Affected errors:
espflash:StubRequired(erase-region),InvalidEraseRegionArgument,ImageFormatMismatch,FirmwareChipMismatch,AppDescriptorNotPresent,ParseChipRevError, the errors ofFlasher::erase_region(erase-parts) andFlasher::verify_minimum_revision.cargo-espflash:StubRequired(erase-parts),NoPackage,Flasher::verify_minimum_revision.The remaining
.into_diagnostic()calls convert errors of other crates (I/O,serialport,toml,esp-idf-part,cargo_metadata), which don't implementDiagnostic.Also removes the double space before "and/or" in the
InvalidEraseRegionArgumentmessage.An AI tool generated a significant part of this change. It is tested on the host, see Testing.
Testing
test_errors_keep_code_and_help:erase_regionwith an unaligned address and with--no-stub, andresolve_image_formatwith a contradicting format, return reports with their code and help. It fails iferase_regiongoes back to.into_diagnostic()..into_diagnostic()#1136 now print the code and help, e.g.:espflash erase-region --no-stub,espflash erase-parts --no-stub,espflash flash --format esp-idf <direct-boot ELF>,cargo espflash erase-parts --no-stubandcargo espflash save-imagein a workspace without a default package (cargo_espflash::no_package).cargo +nightly fmt --check,cargo clippy --all-targets -- -D warnings,cargo clippy -p espflash --no-default-features [--features cli] -- -D warningsandcargo test -p espflash --lib.No HIL run needed: only error reporting changes, and the affected paths fail before or independently of device interaction.