fix(metassr-build): replace panicking Manifest::from() with proper error handling#101
Open
abhicodes0324 wants to merge 1 commit intometacall:masterfrom
Open
Conversation
…ror handling Signed-off-by: Abhiswant Chaudhary <abhicodes0324@gmail.com>
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.
Problem
Manifest::from()called.unwrap()twice with no error context:This causes two real user-facing problems:
Running
metassr runwithout building first -manifest.jsondoesn't exist yet, so the server panics immediately with a cryptic thread panic instead of a clear message.Corrupted or partial build - if
manifest.jsonexists but is malformed, the server panics with no indication of what went wrong.Additionally,
page.rscalledmanifest.get(route).unwrap()which panics if a route exists in the server but not in the manifest.Changes
manifest.rsFrom<&S>implManifest::load()returningResult<Self>with actionable errors:"Could not read manifest.json at ...: Did you run metassr build first?""manifest.json is malformed: ..."renderer/page.rsManifest::from(path)→Manifest::load(path)?manifest.get(route).unwrap()→.ok_or_else(|| anyhow!(...))?Before / After
Note
Could not verify output locally due to the MetaCall native dependency requirement. The correctness of this fix can be verified by code review -
Manifest::load()usesmap_errwith?propagation instead of.unwrap(), making panics structurally impossible for both the missing file and malformed JSON cases.