Skip to content

Commit

Permalink
chore: Hint user to run force build when contract format changes (#1903)
Browse files Browse the repository at this point in the history
  • Loading branch information
chubei committed Aug 24, 2023
1 parent ea5678e commit def4272
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion dozer-cli/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,12 @@ pub enum BuildError {
FieldNotFound(String),
#[error("File system error {0:?}: {1}")]
FileSystem(PathBuf, std::io::Error),
#[error(
"Failed to load existing contract: {0}. You have to run a force build: `dozer build --force`."
)]
FailedToLoadExistingContract(#[source] serde_json::Error),
#[error("Serde json error: {0}")]
SerdeJson(#[from] serde_json::Error),
SerdeJson(#[source] serde_json::Error),
#[error("Failed to generate proto files: {0:?}")]
FailedToGenerateProtoFiles(#[from] GenerationError),
#[error("Storage error: {0}")]
Expand Down
5 changes: 2 additions & 3 deletions dozer-cli/src/simple/build/contract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ fn serde_json_to_path(path: impl AsRef<Path>, value: &impl Serialize) -> Result<
.write(true)
.open(path.as_ref())
.map_err(|e| BuildError::FileSystem(path.as_ref().into(), e))?;
serde_json::to_writer_pretty(file, value)?;
Ok(())
serde_json::to_writer_pretty(file, value).map_err(BuildError::SerdeJson)
}

fn serde_json_from_path<T>(path: impl AsRef<Path>) -> Result<T, BuildError>
Expand All @@ -217,7 +216,7 @@ where
.read(true)
.open(path.as_ref())
.map_err(|e| BuildError::FileSystem(path.as_ref().into(), e))?;
Ok(serde_json::from_reader(file)?)
serde_json::from_reader(file).map_err(BuildError::FailedToLoadExistingContract)
}

mod modify_schema;

0 comments on commit def4272

Please sign in to comment.