-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix panic when invoked on crate missing metadata (#377) #378
Conversation
With this patch instead of panicking the result is now:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help providing clearer errors.
impl/src/settings.rs
Outdated
@@ -626,9 +626,9 @@ fn parse_raze_settings_any_package(metadata: &Metadata) -> Result<RazeSettings> | |||
} | |||
|
|||
// There should only be one package with raze | |||
if settings_packages.len() > 1 { | |||
if settings_packages.len() != 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably worth specifying the zero case separately. Perhaps something like:
No raze settings were specified in the Cargo.toml file, see README.md for details on expected fields
would be more helpful?
also, not your doing, but I'm noticing that
return Err(anyhow!("error message"));
is used. Anyhow provides anyhow::bail
bail!("error message");
that does the same thing, more concisely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably worth specifying the zero case separately. Perhaps something like:
No raze settings were specified in the Cargo.toml file, see README.md for details on expected fields
would be more helpful?
Done. I do worry that it should perhaps be a URL, as if someone is just running cargo-raze as part of CI, etc, that it won't be clear which README.md
is intended in context.
also, not your doing, but I'm noticing that
return Err(anyhow!("error message"));is used. Anyhow provides anyhow::bail
bail!("error message");that does the same thing, more concisely.
Done.
Also add a test that ensures the error is reported and a panic doesn't occur.
c6a0c12
to
dbe5c0b
Compare
great, thanks! |
I appreciate the reviews and merge, thanks! |
Also add a test that ensures the error is reported and a panic doesn't
occur.