Skip to content

Commit ddee839

Browse files
committed
[renderer] Err on bad file names, instead of panic
Addressing the review comments.
1 parent 9994554 commit ddee839

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

build.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ mod execs {
2525
}
2626

2727

28-
// TODO: Drop after error_chain is fixed
29-
#[allow(unused_doc_comment)]
3028
error_chain!{
3129
foreign_links {
3230
Io(std::io::Error);

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ pub use book::BookItem;
100100
pub use renderer::Renderer;
101101

102102
/// The error types used through out this crate.
103-
// TODO: Drop after error_chain is fixed
104-
#[allow(unused_doc_comment)]
105103
pub mod errors {
106104
error_chain!{
107105
foreign_links {

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ impl HtmlHandlebars {
6666
let filepath = Path::new(&ch.path).with_extension("html");
6767
let rendered = self.post_process(rendered,
6868
&normalize_path(filepath.to_str()
69-
.expect(&format!("Bad file name: {}", filepath.display()))),
70-
ctx.book.get_html_config().get_playpen_config());
69+
.ok_or(Error::from(format!("Bad file name: {}", filepath.display())))?),
70+
ctx.book.get_html_config().get_playpen_config()
71+
);
7172

7273
// Write to file
7374
info!("[*] Creating {:?} ✓", filepath.display());
@@ -458,7 +459,7 @@ fn id_from_content(content: &str) -> String {
458459
let mut content = content.to_string();
459460

460461
// Skip any tags or html-encoded stuff
461-
static REPL_SUB: &[&str] = &[
462+
const REPL_SUB: &[&str] = &[
462463
"<em>",
463464
"</em>",
464465
"<code>",

0 commit comments

Comments
 (0)