File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 1
- use anyhow:: { Context , Result } ;
1
+ use anyhow:: { bail , Context , Result } ;
2
2
use serde:: Deserialize ;
3
3
use std:: {
4
4
io:: Read ,
@@ -68,12 +68,16 @@ impl CmdRunner {
68
68
. stdin ( Stdio :: null ( ) )
69
69
. stderr ( Stdio :: inherit ( ) )
70
70
. output ( )
71
- . context ( CARGO_METADATA_ERR ) ?
72
- . stdout ;
71
+ . context ( CARGO_METADATA_ERR ) ?;
73
72
74
- let target_dir = serde_json:: de:: from_slice :: < CargoMetadata > ( & metadata_output)
75
- . context ( "Failed to read the field `target_directory` from the `cargo metadata` output" )
76
- . map ( |metadata| metadata. target_directory ) ?;
73
+ if !metadata_output. status . success ( ) {
74
+ bail ! ( "The command `cargo metadata …` failed. Are you in the `rustlings/` directory?" ) ;
75
+ }
76
+
77
+ let target_dir = serde_json:: de:: from_slice :: < CargoMetadata > ( & metadata_output. stdout )
78
+ . context (
79
+ "Failed to read the field `target_directory` from the output of the command `cargo metadata …`" ,
80
+ ) ?. target_directory ;
77
81
78
82
Ok ( Self { target_dir } )
79
83
}
You can’t perform that action at this time.
0 commit comments