fix: return Result from draw() and save_gexf() (closes #33) - #34
Open
Dani-giron wants to merge 3 commits into
Open
fix: return Result from draw() and save_gexf() (closes #33)#34Dani-giron wants to merge 3 commits into
Dani-giron wants to merge 3 commits into
Conversation
Author
3 tasks
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.
Summary
draw()exports the HNSW graph to GEXF files and had two silent failure modes.gexf.to_string()can fail and was called through.unwrap(), which panics the whole process on a serialization error instead of surfacing it. Separately,draw()calledsave_gexf()throughlet _ = ..., discarding itsstd::io::Resultand swallowing I/O errors fromfs::write(disk full, no permission, invalid path) while still returning as if the export had succeeded.Changes
src/controllers/apotheosis.rs: bothdraw()and the privatesave_gexf()now returnResult<(), Box<dyn std::error::Error>>. Theto_string()calls use?instead of.unwrap(), and thesave_gexf()call indraw()uses?instead oflet _ =.GexfErrorfrom thegexfcrate already implementsstd::error::Errorviathiserror, so it converts intoBox<dyn std::error::Error>through?with no extra work.src/orsrc/bin/callsdraw(), so nothing there needed updating.tests/api_contract.rs:draw_produces_one_gexf_file_per_layer, the one test callingdraw(), now calls.expect()on the result.Test plan
Verified locally with the same commands CI runs:
cargo clippy --all-targets --all-features -- -D warningsclean,cargo fmt --checkclean, and all 44 tests passing.Also reproduced the silent I/O failure live before fixing it: calling
draw()with a path whose parent directory does not exist returnedOkwith no panic and no file written, confirming the bug was real and not just a static-analysis finding.Closes #33.