Skip to content

Commit

Permalink
fix: improve error handling for missing output.html.print setting (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-dlee authored Dec 5, 2023
1 parent 7250bba commit 1015b6f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "GPL-3.0"
name = "mdbook-pdf"
readme = "README.md"
repository = "https://github.com/HollowMan6/mdbook-pdf"
version = "0.1.7"
version = "0.1.8"
include = [
"**/*.rs",
"Cargo.toml",
Expand Down
13 changes: 13 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.unwrap()
.to_owned();

if !PathBuf::from(&print_html_path).exists() {
println!(
"PDF generation failed. The print.html file does not exist at {}.",
print_html_path
);
println!("Verify output.html is active and output.html.print.enabled is set to true in your book.toml.");
return Err(Box::try_from(io::Error::new(
io::ErrorKind::NotFound,
format!("File not found: {}", print_html_path),
))
.unwrap());
}

// Modify the print.html for custom JS scripts as well as links outside the book.
let file = fs::OpenOptions::new()
.read(true)
Expand Down

0 comments on commit 1015b6f

Please sign in to comment.