Skip to content

Commit a3d4feb

Browse files
authored
Provide useful feedback if user executes command in different folder (#1407)
Provides better feedback if user executes in a different folder than what is expected by mdbook After the changes `mdbook build` ``` 2020-12-19 14:27:35 [ERROR] (mdbook::utils): Error: Couldn't open SUMMARY.md in "/Users/vicky/rust/source_codes/mdbook_testing/src/src" directory 2020-12-19 14:27:35 [ERROR] (mdbook::utils): Caused By: No such file or directory (os error 2) ``` Previously: `mdbook build` ``` 2020-12-19 14:28:46 [ERROR] (mdbook::utils): Error: Couldn't open SUMMARY.md 2020-12-19 14:28:46 [ERROR] (mdbook::utils): Caused By: No such file or directory (os error 2) ```
1 parent 7af4b1d commit a3d4feb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/book/book.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ pub fn load_book<P: AsRef<Path>>(src_dir: P, cfg: &BuildConfig) -> Result<Book>
1414
let summary_md = src_dir.join("SUMMARY.md");
1515

1616
let mut summary_content = String::new();
17-
File::open(summary_md)
18-
.with_context(|| "Couldn't open SUMMARY.md")?
17+
File::open(&summary_md)
18+
.with_context(|| format!("Couldn't open SUMMARY.md in {:?} directory", src_dir))?
1919
.read_to_string(&mut summary_content)?;
2020

21-
let summary = parse_summary(&summary_content).with_context(|| "Summary parsing failed")?;
21+
let summary = parse_summary(&summary_content)
22+
.with_context(|| format!("Summary parsing failed for file={:?}", summary_md))?;
2223

2324
if cfg.create_missing {
2425
create_missing(&src_dir, &summary).with_context(|| "Unable to create missing chapters")?;

0 commit comments

Comments
 (0)