Skip to content

Commit

Permalink
update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed Oct 29, 2023
1 parent 726e430 commit 2e2ae60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tooling/nargo_toml/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub enum ManifestError {

#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum SemverError {
#[error("Incompatible compiler version in package {package_name}. Required version is {required_compiler_version} but the compiler version is {compiler_version_found}")]
#[error("Incompatible compiler version in package {package_name}. Required compiler version is {required_compiler_version} but the compiler version is {compiler_version_found}.\n Update the compiler_version field in Nargo.toml to >={compiler_version_found} or compile this project with version {compiler_version_found}")]
IncompatibleVersion {
package_name: CrateName,
required_compiler_version: String,
Expand Down
9 changes: 8 additions & 1 deletion tooling/nargo_toml/src/semver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub(crate) fn semver_check_package(
return Err(SemverError::IncompatibleVersion {
package_name: package.name.clone(),
required_compiler_version: version.clone(),
compiler_version_found: compiler_version.to_string(),
compiler_version_found: strip_build_meta_data(compiler_version),
});
};
}
Expand All @@ -56,6 +56,13 @@ pub(crate) fn semver_check_package(
Ok(())
}

// Strip the build meta data from the version string since it is ignored by semver.
fn strip_build_meta_data(version: &Version) -> String {
let version_string = version.to_string();
let mut split = version_string.split('+');
split.next().expect("split was called on an empty string").to_string()
}

#[cfg(test)]
mod tests {
use std::{collections::BTreeMap, path::PathBuf, str::FromStr};
Expand Down

0 comments on commit 2e2ae60

Please sign in to comment.