<commit_before>extern crate iron;
extern crate handlebars_iron as hbs;
extern crate rustc_serialize;

use std::error::Error;
use iron::prelude::*;
use iron::{status, AfterMiddleware};
use hbs::{Template, HandlebarsEngine, DirectorySource};

/// the handler
fn hello_world(_: &mut Request) -> IronResult<Response> {
    let mut resp = Response::new();

    let data = "".to_owned();
    resp.set_mut(Template::new("not-exist", data)).set_mut(status::Ok);
    Ok(resp)
}

struct ErrorReporter;

impl AfterMiddleware for ErrorReporter {
    fn catch(&self, _: &mut Request, err: IronError) -> IronResult<Response> {
        println!("{}", err.description());
        Err(err)
    }
}

fn main() {
    let mut chain = Chain::new(hello_world);
    let mut hbse = HandlebarsEngine::new2();
    hbse.add(Box::new(DirectorySource::new("./examples/templates/", ".hbs")));
    // success of panic
    if let Err(r) = hbse.reload() {<commit_msg>(fix) remove unused imports<commit_after>extern crate iron;
extern crate handlebars_iron as hbs;

use std::error::Error;
use iron::prelude::*;
use iron::{status, AfterMiddleware};
use hbs::{Template, HandlebarsEngine, DirectorySource};

/// the handler
fn hello_world(_: &mut Request) -> IronResult<Response> {
    let mut resp = Response::new();

    let data = "".to_owned();
    resp.set_mut(Template::new("not-exist", data)).set_mut(status::Ok);
    Ok(resp)
}

struct ErrorReporter;

impl AfterMiddleware for ErrorReporter {
    fn catch(&self, _: &mut Request, err: IronError) -> IronResult<Response> {
        println!("{}", err.description());
        Err(err)
    }
}

fn main() {
    let mut chain = Chain::new(hello_world);
    let mut hbse = HandlebarsEngine::new2();
    hbse.add(Box::new(DirectorySource::new("./examples/templates/", ".hbs")));
    // success of panic
    if let Err(r) = hbse.reload() {
{'fraction_non_alphanumeric': 0.16468682505399568, 'fraction_numerical': 0.0010799136069114472, 'mean_word_length': 4.2492917847025495, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1307900', 'n_tokens_mistral': 606, 'n_tokens_neox': 600, 'n_words': 148}