Skip to content

Commit 8b08666

Browse files
Merge #10334
10334: Give rustfmt spawn error context. r=jonas-schievink a=aDotInTheVoid This mean if you misconfigure to ```json { "rust-analyzer.rustfmt.overrideCommand": [ "./nonono" ] } ``` The error message is ``` [Error - 17:54:33] Request textDocument/formatting failed. Message: Failed to spawn "./nonono" Code: -32603 ``` instead of ``` [Error - 17:56:12] Request textDocument/formatting failed. Message: No such file or directory (os error 2) Code: -32603 ``` I'm not sure how to test this, or if it needs a test. Co-authored-by: Nixon Enraght-Moony <[email protected]>
2 parents 5d948ca + 720a3da commit 8b08666

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/rust-analyzer/src/handlers.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{
77
process::{self, Stdio},
88
};
99

10+
use anyhow::Context;
1011
use ide::{
1112
AnnotationConfig, AssistKind, AssistResolveStrategy, FileId, FilePosition, FileRange,
1213
HoverAction, HoverGotoTypeData, Query, RangeInfo, Runnable, RunnableKind, SingleResolve,
@@ -1696,8 +1697,12 @@ fn run_rustfmt(
16961697
}
16971698
};
16981699

1699-
let mut rustfmt =
1700-
rustfmt.stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::piped()).spawn()?;
1700+
let mut rustfmt = rustfmt
1701+
.stdin(Stdio::piped())
1702+
.stdout(Stdio::piped())
1703+
.stderr(Stdio::piped())
1704+
.spawn()
1705+
.context(format!("Failed to spawn {:?}", rustfmt))?;
17011706

17021707
rustfmt.stdin.as_mut().unwrap().write_all(file.as_bytes())?;
17031708

0 commit comments

Comments
 (0)