Skip to content

Commit

Permalink
fix: catch error on dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Jul 31, 2024
1 parent ecd9f8f commit 6c3a0ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/cairo-runner/src/dry_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ impl DryRunner {

let input_file_path = &NamedTempFile::new()?.path().to_path_buf();
fs::write(input_file_path, input_string).expect("Failed to write input file");
let _ = self._run(input_file_path)?;
let output = self._run(input_file_path)?;
if output.is_empty() {
return Err(CairoRunnerError::CairoRunError);
}

// parse output to return dry run result
let dry_run_result = self.parse_run(&PathBuf::from(DRY_CAIRO_RUN_OUTPUT_FILE))?;
Expand All @@ -73,6 +76,7 @@ impl DryRunner {
/// Parse the output of the dry run command
fn parse_run(&self, input_file_path: &Path) -> Result<DryRunResult, CairoRunnerError> {
let output = fs::read_to_string(input_file_path)?;

let fetch_keys: Vec<DryRunnedModule> = serde_json::from_str(&output)?;
fs::remove_file(input_file_path).expect("Failed to remove input file");
if let Some(ref output_path) = self.output_file_path {
Expand Down

0 comments on commit 6c3a0ff

Please sign in to comment.