Skip to content

Commit

Permalink
Better error message when deserializing RegistryPackage (#180)
Browse files Browse the repository at this point in the history
Currently, when a component dependency is specified as a string
it is assumed to be the version of the dependency on the registry.
If, however, the user thinks that this could be path to a local wit
definition, the error message is very confusing.

This changes adds a bit more context so hopefully the issue is clearer.
  • Loading branch information
rylev authored Nov 6, 2023
1 parent 33b5246 commit 10e84f4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ impl FromStr for RegistryPackage {
fn from_str(s: &str) -> Result<Self> {
Ok(Self {
id: None,
version: s.parse()?,
version: s
.parse()
.with_context(|| format!("'{s}' is an invalid registry package version"))?,
registry: None,
})
}
Expand Down

0 comments on commit 10e84f4

Please sign in to comment.