Skip to content

Commit 9ca0856

Browse files
committed
Don't panic if JSON backend fails to create a file
1 parent d99ec1d commit 9ca0856

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/librustdoc/json/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ impl FormatRenderer for JsonRenderer {
227227
let mut p = self.out_path.clone();
228228
p.push(output.index.get(&output.root).unwrap().name.clone().unwrap());
229229
p.set_extension("json");
230-
serde_json::ser::to_writer_pretty(&File::create(p).unwrap(), &output).unwrap();
230+
let file = File::create(&p).map_err(|error| Error { error: error.to_string(), file: p })?;
231+
serde_json::ser::to_writer_pretty(&file, &output).unwrap();
231232
Ok(())
232233
}
233234

0 commit comments

Comments
 (0)