Skip to content

Commit

Permalink
feat: add a helpful error message for missing names in Nargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Jul 27, 2023
1 parent 551de53 commit b3bdb49
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions crates/nargo/src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub struct WorkspaceConfig {
#[allow(dead_code)]
#[derive(Default, Debug, Deserialize, Clone)]
pub struct PackageMetadata {
#[serde(default = "panic_missing_name")]
pub name: String,
description: Option<String>,
authors: Vec<String>,
Expand All @@ -77,6 +78,26 @@ pub struct PackageMetadata {
license: Option<String>,
}

// TODO: Remove this after a couple of breaking releases (added in 0.10.0)
fn panic_missing_name() -> String {
panic!(
r#"
Failed to parse `Nargo.toml`.
`Nargo.toml` now requires a "name" field for Noir packages.
```toml
[package]
name = "package_name"
```
Modify your `Nargo.toml` similarly to above and rerun the command.
"#
)
}

#[derive(Debug, Deserialize, Clone)]
#[serde(untagged)]
/// Enum representing the different types of ways to
Expand Down

0 comments on commit b3bdb49

Please sign in to comment.