Skip to content

Commit

Permalink
Don't panic if JSON backend fails to create a file
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Nov 8, 2020
1 parent d99ec1d commit 9ca0856
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ impl FormatRenderer for JsonRenderer {
let mut p = self.out_path.clone();
p.push(output.index.get(&output.root).unwrap().name.clone().unwrap());
p.set_extension("json");
serde_json::ser::to_writer_pretty(&File::create(p).unwrap(), &output).unwrap();
let file = File::create(&p).map_err(|error| Error { error: error.to_string(), file: p })?;
serde_json::ser::to_writer_pretty(&file, &output).unwrap();
Ok(())
}

Expand Down

0 comments on commit 9ca0856

Please sign in to comment.